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,51 +25,55 @@ use Thelia\Model\Lang;
*/ */
class BrandCreationForm extends BaseForm 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() protected function buildForm()
{ {
$this->formBuilder $this->doBuilForm(
// Brand title Translator::getInstance()->trans(
->add( 'Enter here the brand name in the default language (%title%)',
'title', [ '%title%' => Lang::getDefaultLanguage()->getTitle()]
'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'),
]
]
) )
// 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() public function getName()

View File

@@ -28,42 +28,27 @@ 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', [
[ 'constraints' => [ new GreaterThan(['value' => 0]) ],
'constraints' => [ new GreaterThan(['value' => 0]) ], 'required' => true,
'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 // Add standard description fields, excluding title and locale, which are already defined

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"}>