Improved brand form declarations

This commit is contained in:
Franck Allimant
2014-07-04 11:54:02 +02:00
parent f46168f518
commit a57d668e3c
3 changed files with 66 additions and 77 deletions

View File

@@ -25,11 +25,9 @@ use Thelia\Model\Lang;
*/ */
class BrandCreationForm extends BaseForm class BrandCreationForm extends BaseForm
{ {
protected function buildForm() protected function doBuilForm($titleFieldHelpLabel)
{ {
$this->formBuilder $this->formBuilder->add(
// Brand title
->add(
'title', 'title',
'text', 'text',
[ [
@@ -38,17 +36,13 @@ class BrandCreationForm extends BaseForm
'label' => Translator::getInstance()->trans('Brand name'), 'label' => Translator::getInstance()->trans('Brand name'),
'label_attr' => [ 'label_attr' => [
'for' => 'title', 'for' => 'title',
'help' => Translator::getInstance()->trans( 'help' => $titleFieldHelpLabel
'Enter here the brand name in the default language (%title%)',
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
),
], ],
'attr' => [ 'attr' => [
'placeholder' => Translator::getInstance()->trans('The brand name or title'), 'placeholder' => Translator::getInstance()->trans('The brand name or title'),
] ]
] ]
) )
// Current locale
->add( ->add(
'locale', 'locale',
'hidden', 'hidden',
@@ -63,7 +57,7 @@ class BrandCreationForm extends BaseForm
'checkbox', 'checkbox',
[ [
'constraints' => [ ], 'constraints' => [ ],
'required' => true, 'required' => false,
'label' => Translator::getInstance()->trans('This brand is online'), 'label' => Translator::getInstance()->trans('This brand is online'),
'label_attr' => [ 'label_attr' => [
'for' => 'visible_create' 'for' => 'visible_create'
@@ -72,6 +66,16 @@ class BrandCreationForm extends BaseForm
); );
} }
protected function buildForm()
{
$this->doBuilForm(
Translator::getInstance()->trans(
'Enter here the brand name in the default language (%title%)',
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
)
);
}
public function getName() public function getName()
{ {
return 'thelia_brand_creation'; return 'thelia_brand_creation';

View File

@@ -28,10 +28,11 @@ class BrandModificationForm extends BrandCreationForm
protected function buildForm() protected function buildForm()
{ {
parent::buildForm(); $this->doBuilForm(
Translator::getInstance()->trans('The brand name or title')
);
$this->formBuilder $this->formBuilder->add(
->add(
'id', 'id',
'hidden', 'hidden',
[ [
@@ -39,22 +40,6 @@ class BrandModificationForm extends BrandCreationForm
'required' => true, 'required' => true,
] ]
) )
// 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", [ ->add("logo_image_id", "integer", [
'constraints' => [ ], 'constraints' => [ ],
'required' => false, 'required' => false,

View File

@@ -200,7 +200,7 @@
{* Switch edition to the current locale *} {* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" /> <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"> <div class="input-group">
<input type="text" {form_field_attributes form=$form field="title"}> <input type="text" {form_field_attributes form=$form field="title"}>