Improved brand form declarations
This commit is contained in:
@@ -25,51 +25,55 @@ use Thelia\Model\Lang;
|
||||
*/
|
||||
class BrandCreationForm extends BaseForm
|
||||
{
|
||||
protected function doBuilForm($titleFieldHelpLabel)
|
||||
{
|
||||
$this->formBuilder->add(
|
||||
'title',
|
||||
'text',
|
||||
[
|
||||
'constraints' => [ new NotBlank() ],
|
||||
'required' => true,
|
||||
'label' => Translator::getInstance()->trans('Brand name'),
|
||||
'label_attr' => [
|
||||
'for' => 'title',
|
||||
'help' => $titleFieldHelpLabel
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
|
||||
]
|
||||
]
|
||||
)
|
||||
->add(
|
||||
'locale',
|
||||
'hidden',
|
||||
[
|
||||
'constraints' => [ new NotBlank() ],
|
||||
'required' => true,
|
||||
]
|
||||
)
|
||||
// Is this brand online ?
|
||||
->add(
|
||||
'visible',
|
||||
'checkbox',
|
||||
[
|
||||
'constraints' => [ ],
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('This brand is online'),
|
||||
'label_attr' => [
|
||||
'for' => 'visible_create'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
// Brand title
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
[
|
||||
'constraints' => [ new NotBlank() ],
|
||||
'required' => true,
|
||||
'label' => Translator::getInstance()->trans('Brand name'),
|
||||
'label_attr' => [
|
||||
'for' => 'title',
|
||||
'help' => Translator::getInstance()->trans(
|
||||
'Enter here the brand name in the default language (%title%)',
|
||||
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
|
||||
),
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
|
||||
]
|
||||
]
|
||||
$this->doBuilForm(
|
||||
Translator::getInstance()->trans(
|
||||
'Enter here the brand name in the default language (%title%)',
|
||||
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
|
||||
)
|
||||
// Current locale
|
||||
->add(
|
||||
'locale',
|
||||
'hidden',
|
||||
[
|
||||
'constraints' => [ new NotBlank() ],
|
||||
'required' => true,
|
||||
]
|
||||
)
|
||||
// Is this brand online ?
|
||||
->add(
|
||||
'visible',
|
||||
'checkbox',
|
||||
[
|
||||
'constraints' => [ ],
|
||||
'required' => true,
|
||||
'label' => Translator::getInstance()->trans('This brand is online'),
|
||||
'label_attr' => [
|
||||
'for' => 'visible_create'
|
||||
]
|
||||
]
|
||||
);
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
@@ -28,42 +28,27 @@ class BrandModificationForm extends BrandCreationForm
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
$this->doBuilForm(
|
||||
Translator::getInstance()->trans('The brand name or title')
|
||||
);
|
||||
|
||||
$this->formBuilder
|
||||
->add(
|
||||
'id',
|
||||
'hidden',
|
||||
[
|
||||
'constraints' => [ new GreaterThan(['value' => 0]) ],
|
||||
'required' => true,
|
||||
$this->formBuilder->add(
|
||||
'id',
|
||||
'hidden',
|
||||
[
|
||||
'constraints' => [ new GreaterThan(['value' => 0]) ],
|
||||
'required' => true,
|
||||
]
|
||||
)
|
||||
->add("logo_image_id", "integer", [
|
||||
'constraints' => [ ],
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Select the brand logo'),
|
||||
'label_attr' => [
|
||||
'for' => 'mode',
|
||||
'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")
|
||||
]
|
||||
)
|
||||
// Brand title
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
[
|
||||
'constraints' => [ new NotBlank() ],
|
||||
'required' => true,
|
||||
'label' => Translator::getInstance()->trans('Brand name'),
|
||||
'label_attr' => [
|
||||
'for' => 'title'
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title')
|
||||
]
|
||||
]
|
||||
)
|
||||
->add("logo_image_id", "integer", [
|
||||
'constraints' => [ ],
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Select the brand logo'),
|
||||
'label_attr' => [
|
||||
'for' => 'mode',
|
||||
'help' => Translator::getInstance()->trans("Select the brand logo amongst the brand images")
|
||||
]
|
||||
])
|
||||
])
|
||||
;
|
||||
|
||||
// Add standard description fields, excluding title and locale, which are already defined
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{render_form_field field="locale" value=$LOCALE}
|
||||
{render_form_field form=$form field="locale" value=$LOCALE}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" {form_field_attributes form=$form field="title"}>
|
||||
|
||||
Reference in New Issue
Block a user