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
{
protected function buildForm()
protected function doBuilForm($titleFieldHelpLabel)
{
$this->formBuilder
// Brand title
->add(
$this->formBuilder->add(
'title',
'text',
[
@@ -38,17 +36,13 @@ class BrandCreationForm extends BaseForm
'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()]
),
'help' => $titleFieldHelpLabel
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
]
]
)
// Current locale
->add(
'locale',
'hidden',
@@ -63,7 +57,7 @@ class BrandCreationForm extends BaseForm
'checkbox',
[
'constraints' => [ ],
'required' => true,
'required' => false,
'label' => Translator::getInstance()->trans('This brand is online'),
'label_attr' => [
'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()
{
return 'thelia_brand_creation';

View File

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

View File

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