language form-add new field
Forum rules
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
language form-add new field
Hi,
i am a laravel developer.I am using laravel 8 and i have integrated aimeos with laravel.I was given a task to add new field to languages form for which i have done following steps.
1) i created file item-standard in direcotory ext\ai-moudhah\admin\jqadm\templates\locale\language
and added field
2) i added locale file in the directory ext\ai-moudhah\lib\custom\setup\default\schema which contains
and field is added succesfully in table.
3) i made a decorator Myproject.php in the directory
ext\ai-moudhah\lib\custom\src\MShop\Locale\Manager\Language\Decorator which contains
4) at last i added code in config/mshop.php
now i am trying to save data but it is giving me error and not saving data.i am totally stuck and dont know what to
do
please help me so i can proceed in my project
i am a laravel developer.I am using laravel 8 and i have integrated aimeos with laravel.I was given a task to add new field to languages form for which i have done following steps.
1) i created file item-standard in direcotory ext\ai-moudhah\admin\jqadm\templates\locale\language
and added field
2) i added locale file in the directory ext\ai-moudhah\lib\custom\setup\default\schema which contains
Code: Select all
return array(
'table' => array(
'mshop_locale_language' => function ( \Doctrine\DBAL\Schema\Schema $schema ) {
$table = $schema->getTable( 'mshop_locale_language' );
$table->addColumn( 'test', 'string', array( 'length' => 32, 'notnull' => true ) );
return $schema;
},
),
);
3) i made a decorator Myproject.php in the directory
ext\ai-moudhah\lib\custom\src\MShop\Locale\Manager\Language\Decorator which contains
Code: Select all
<?php
namespace Aimeos\MShop\Locale\Manager\Language\Decorator;
class Myproject extends \Aimeos\MShop\Common\Manager\Decorator\Base
{
private $attr = array(
'locale.language.test'=> array(
'code'=>'locale.language.test',
'internalcode'=>'mlocla."test"',
'label'=>'Site city',
'type'=> 'string', // integer, float, etc.
'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR, // _INT, _FLOAT, etc.
),
);
public function getSaveAttributes() : array
{
return parent::getSaveAttributes() + $this->createAttributes( $this->attr );
}
public function getSearchAttributes( $sub = true ) :array
{
return parent::getSearchAttributes( $sub ) + $this->createAttributes( $this->attr );
}
}
4) at last i added code in config/mshop.php
Code: Select all
'locale' => [
'manager' => [
'language' => [
'decorators' => [
'local' => ['Myproject']
]
]
]
]
do
please help me so i can proceed in my project
Re: language form-add new field
Check in the Log panel (extended left navigation) for the error details.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: language form-add new field
You haven't executed
to update the database and add the new field.
Code: Select all
php artisan aimeos:setup
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: language form-add new field
actually i have run that command and table field is created.The problem is that the value is not passing from view to manageraimeos wrote: ↑25 Jan 2021, 07:56 You haven't executedto update the database and add the new field.Code: Select all
php artisan aimeos:setup
please tell me am i missing some thing
and also please tell me do i need to extend standard class in item directory or it is not necessary because currently i made only
a decorator ,overwritten template file and added field in datatabase.please guide me if i missed something
Re: language form-add new field
It seems like your new decorator isn't used for some reason because "locale.language.test" isn't translated to mlocla."test" in the query. Can you please post the complete ./config/mshop.php file?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: language form-add new field
Code: Select all
return [
'locale' => [
'manager' => [
'language' => [
'decorators' => [
'local' => ['Myproject']
]
]
]
]
];
view is not passing to the manager file becuase when i hard code the value
Code: Select all
namespace Aimeos\MShop\Locale\Manager\Language;
foreach( $columns as $name => $entry ) {
$stmt->bind( $idx++, $item->get( $name ), $entry->getInternalType() );
}
no new field in the bdata array (which is inside $item variable)
Re: language form-add new field
Please check what happens in the fromArray() method of the locale language item resp. in the common item if the value is there:
- https://github.com/aimeos/aimeos-core/b ... d.php#L148
- https://github.com/aimeos/aimeos-core/b ... #L387-L393
Is the value you are passing there? If not, then it's most likely a problem with the name attribute of your input field in your extended template from the admin panel. How does that code look like?
- https://github.com/aimeos/aimeos-core/b ... d.php#L148
- https://github.com/aimeos/aimeos-core/b ... #L387-L393
Is the value you are passing there? If not, then it's most likely a problem with the name attribute of your input field in your extended template from the admin panel. How does that code look like?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star
Re: language form-add new field
This is the template file of language form and it contains test field which i have added and it is showing on the screenaimeos wrote: ↑26 Jan 2021, 08:25 Please check what happens in the fromArray() method of the locale language item resp. in the common item if the value is there:
- https://github.com/aimeos/aimeos-core/b ... d.php#L148
- https://github.com/aimeos/aimeos-core/b ... #L387-L393
Is the value you are passing there? If not, then it's most likely a problem with the name attribute of your input field in your extended template from the admin panel. How does that code look like?
correctly
directory ext\moudhah\admin\jqadm\templates\locale\language
Code: Select all
<?php
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2017-2020
*/
$selected = function( $key, $code ) {
return ( $key == $code ? 'selected="selected"' : '' );
};
$enc = $this->encoder();
$target = $this->config( 'admin/jqadm/url/save/target' );
$cntl = $this->config( 'admin/jqadm/url/save/controller', 'Jqadm' );
$action = $this->config( 'admin/jqadm/url/save/action', 'save' );
$config = $this->config( 'admin/jqadm/url/save/config', [] );
$params = $this->get( 'pageParams', [] );
?>
<?php $this->block()->start( 'jqadm_content' ); ?>
<form class="item item-locale form-horizontal" method="POST" enctype="multipart/form-data" action="<?= $enc->attr( $this->url( $target, $cntl, $action, $params, [], $config ) ); ?>">
<input id="item-id" type="hidden" name="<?= $enc->attr( $this->formparam( array( 'item', 'locale.language.id' ) ) ); ?>" value="<?= $enc->attr( $this->get( 'itemData/locale.language.id' ) ); ?>" />
<input id="item-next" type="hidden" name="<?= $enc->attr( $this->formparam( array( 'next' ) ) ); ?>" value="get" />
<?= $this->csrf()->formfield(); ?>
<nav class="main-navbar">
<h1 class="navbar-brand">
<span class="navbar-title"><?= $enc->html( $this->translate( 'admin', 'Language' ) ); ?></span>
<span class="navbar-id"><?= $enc->html( $this->get( 'itemData/locale.language.id' ) ); ?></span>
<span class="navbar-label"><?= $enc->html( $this->get( 'itemData/locale.language.label' ) ?: $this->translate( 'admin', 'New' ) ); ?></span>
</h1>
<div class="item-actions">
<?= $this->partial( $this->config( 'admin/jqadm/partial/itemactions', 'common/partials/itemactions-standard' ), ['params' => $params] ); ?>
</div>
</nav>
<div class="row item-container">
<div class="col-md-3 item-navbar">
<div class="navbar-content">
<ul class="nav nav-tabs flex-md-column flex-wrap d-flex justify-content-between" role="tablist">
<li class="nav-item basic">
<a class="nav-link active" href="#basic" data-toggle="tab" role="tab" aria-expanded="true" aria-controls="basic">
<?= $enc->html( $this->translate( 'admin', 'Basic' ) ); ?>
</a>
</li>
<?php foreach( array_values( $this->get( 'itemSubparts', [] ) ) as $idx => $subpart ) : ?>
<li class="nav-item <?= $enc->attr( $subpart ); ?>">
<a class="nav-link" href="#<?= $enc->attr( $subpart ); ?>" data-toggle="tab" role="tab" tabindex="<?= ++$idx + 1; ?>">
<?= $enc->html( $this->translate( 'admin', $subpart ) ); ?>
</a>
</li>
<?php endforeach; ?>
</ul>
<div class="item-meta text-muted">
<small>
<?= $enc->html( $this->translate( 'admin', 'Modified' ) ); ?>:
<span class="meta-value"><?= $enc->html( $this->get( 'itemData/locale.language.mtime' ) ); ?></span>
</small>
<small>
<?= $enc->html( $this->translate( 'admin', 'Created' ) ); ?>:
<span class="meta-value"><?= $enc->html( $this->get( 'itemData/locale.language.ctime' ) ); ?></span>
</small>
<small>
<?= $enc->html( $this->translate( 'admin', 'Editor' ) ); ?>:
<span class="meta-value"><?= $enc->html( $this->get( 'itemData/locale.language.editor' ) ); ?></span>
</small>
</div>
</div>
</div>
<div class="col-md-9 item-content tab-content">
<div id="basic" class="row item-basic tab-pane fade show active" role="tabpanel" aria-labelledby="basic">
<div class="col-xl-6 content-block">
<div class="form-group row mandatory">
<label class="col-sm-4 form-control-label"><?= $enc->html( $this->translate( 'admin', 'Status' ) ); ?></label>
<div class="col-sm-8">
<select class="form-control custom-select item-status" required="required" tabindex="1"
name="<?= $enc->attr( $this->formparam( array( 'item', 'locale.language.status' ) ) ); ?>" >
<option value="">
<?= $enc->attr( $this->translate( 'admin', 'Please select' ) ); ?>
</option>
<option value="1" <?= $selected( $this->get( 'itemData/locale.language.status', 1 ), 1 ); ?> >
<?= $enc->html( $this->translate( 'mshop/code', 'status:1' ) ); ?>
</option>
<option value="0" <?= $selected( $this->get( 'itemData/locale.language.status', 1 ), 0 ); ?> >
<?= $enc->html( $this->translate( 'mshop/code', 'status:0' ) ); ?>
</option>
<option value="-1" <?= $selected( $this->get( 'itemData/locale.language.status', 1 ), -1 ); ?> >
<?= $enc->html( $this->translate( 'mshop/code', 'status:-1' ) ); ?>
</option>
<option value="-2" <?= $selected( $this->get( 'itemData/locale.language.status', 1 ), -2 ); ?> >
<?= $enc->html( $this->translate( 'mshop/code', 'status:-2' ) ); ?>
</option>
</select>
</div>
</div>
<div class="form-group row mandatory">
<label class="col-sm-4 form-control-label help"><?= $enc->html( $this->translate( 'admin', 'Code' ) ); ?></label>
<div class="col-sm-8">
<input class="form-control item-code" required="required" tabindex="1" autocomplete="off"
name="<?= $enc->attr( $this->formparam( array( 'item', 'locale.language.code' ) ) ); ?>"
placeholder="<?= $enc->attr( $this->translate( 'admin', 'ISO language code (required)' ) ); ?>"
value="<?= $enc->attr( $this->get( 'itemData/locale.language.code' ) ); ?>" />
</div>
<div class="col-sm-12 form-text text-muted help-text">
<?= $enc->html( $this->translate( 'admin', 'Two letter ISO language code' ) ); ?>
</div>
</div>
<div class="form-group row mandatory">
<label class="col-sm-4 form-control-label help"><?= $enc->html( $this->translate( 'admin', 'Label' ) ); ?></label>
<div class="col-sm-8">
<input class="form-control item-label" required="required" tabindex="1" autocomplete="off"
name="<?= $enc->attr( $this->formparam( array( 'item', 'locale.language.label' ) ) ); ?>"
placeholder="<?= $enc->attr( $this->translate( 'admin', 'Label (required)' ) ); ?>"
value="<?= $enc->attr( $this->get( 'itemData/locale.language.label' ) ); ?>" />
</div>
<div class="col-sm-12 form-text text-muted help-text">
<?= $enc->html( $this->translate( 'admin', 'Descritive name of the language' ) ); ?>
</div>
</div>
// this is the test field
<div class="form-group row mandatory">
<label class="col-sm-4 form-control-label help"><?= $enc->html( $this->translate( 'admin', 'Test Field' ) ); ?></label>
<div class="col-sm-8">
<input class="form-control item-label" required="required" tabindex="1" autocomplete="off"
name="<?= $enc->attr( $this->formparam( array( 'item', 'locale.language.test' ) ) ); ?>"
placeholder="<?= $enc->attr( $this->translate( 'admin', 'Label (required)' ) ); ?>"
value="<?= $enc->attr( $this->get( 'itemData/locale.language.test' ) ); ?>" />
</div>
<div class="col-sm-12 form-text text-muted help-text">
<?= $enc->html( $this->translate( 'admin', 'Descritive name of the language' ) ); ?>
</div>
</div>
</div>
</div>
<?= $this->get( 'itemBody' ); ?>
</div>
<div class="item-actions">
<?= $this->partial( $this->config( 'admin/jqadm/partial/itemactions', 'common/partials/itemactions-standard' ), ['params' => $params] ); ?>
</div>
</div>
</form>
<?php $this->block()->stop(); ?>
<?= $this->render( $this->config( 'admin/jqadm/template/page', 'common/page-standard' ) ); ?>
code is also posted above please tell me specifically do i have to add more things or not because you can say there are no
from array method in decorator. do i need to add it or not
Re: language form-add new field
You've done all necessary steps and I can't see anything missing. There's just an error somewhere. Did you check what's happening in the fromArray() methods for which I've added the links?
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, give us a star
If you like Aimeos, give us a star