Refined the form fields html bindings
This commit is contained in:
@@ -38,12 +38,13 @@ class BrandCreationForm extends BaseForm
|
||||
'label' => Translator::getInstance()->trans('Brand name'),
|
||||
'label_attr' => [
|
||||
'for' => 'title',
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
|
||||
'help' => Translator::getInstance()->trans(
|
||||
'Enter here the brand name in the default language (%title%)',
|
||||
[ '%title%' => Lang::getDefaultLanguage()->getTitle()]
|
||||
),
|
||||
'i18n' => 'default'
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
@@ -48,8 +48,10 @@ class BrandModificationForm extends BrandCreationForm
|
||||
'required' => true,
|
||||
'label' => Translator::getInstance()->trans('Brand name'),
|
||||
'label_attr' => [
|
||||
'for' => 'title',
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title'),
|
||||
'for' => 'title'
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('The brand name or title')
|
||||
]
|
||||
]
|
||||
)
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace Thelia\Form\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Form\StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -22,7 +23,6 @@ use Thelia\Form\BaseForm;
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a file
|
||||
* @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action
|
||||
*
|
||||
* @package File
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
@@ -30,6 +30,8 @@ use Thelia\Form\BaseForm;
|
||||
*/
|
||||
abstract class DocumentModification extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
*/
|
||||
@@ -38,81 +40,18 @@ abstract class DocumentModification extends BaseForm
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
[
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'constraints' => [ ],
|
||||
'label' => Translator::getInstance()->trans('Replace current document by this file'),
|
||||
'label_attr' => array(
|
||||
'label_attr' => [
|
||||
'for' => 'file'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'required' => true,
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Title'),
|
||||
'label_attr' => array(
|
||||
'for' => 'title'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'description',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Description'),
|
||||
'label_attr' => array(
|
||||
'for' => 'description',
|
||||
'rows' => 5
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'chapo',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Chapo'),
|
||||
'label_attr' => array(
|
||||
'for' => 'chapo',
|
||||
'rows' => 3
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum',
|
||||
'rows' => 3
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
"locale",
|
||||
"hidden",
|
||||
array(
|
||||
'required' => true,
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label_attr" => array(
|
||||
"for" => "locale_create"
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
// Add standard description fields
|
||||
$this->addStandardDescFields();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
use Thelia\Form\StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -23,14 +24,14 @@ use Thelia\Form\BaseForm;
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process an image
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class ImageModification extends BaseForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
* @inheritdoc
|
||||
@@ -40,88 +41,24 @@ abstract class ImageModification extends BaseForm
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
[
|
||||
'required' => false,
|
||||
'constraints' => array(
|
||||
'constraints' => [
|
||||
new Image(
|
||||
array(
|
||||
[
|
||||
// 'minWidth' => 200,
|
||||
// 'minHeight' => 200
|
||||
)
|
||||
]
|
||||
)
|
||||
),
|
||||
],
|
||||
'label' => Translator::getInstance()->trans('Replace current image by this file'),
|
||||
'label_attr' => array(
|
||||
'label_attr' => [
|
||||
'for' => 'file'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'required' => true,
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Title'),
|
||||
'label_attr' => array(
|
||||
'for' => 'title'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'description',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Description'),
|
||||
'label_attr' => array(
|
||||
'for' => 'description',
|
||||
'rows' => 5
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'chapo',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Chapo'),
|
||||
'label_attr' => array(
|
||||
'for' => 'chapo',
|
||||
'rows' => 3
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'textarea',
|
||||
array(
|
||||
'required' => false,
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum',
|
||||
'rows' => 3
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
"locale",
|
||||
"hidden",
|
||||
array(
|
||||
'required' => true,
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label_attr" => array(
|
||||
"for" => "locale_create"
|
||||
)
|
||||
)
|
||||
)
|
||||
;
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
// Add standard description fields
|
||||
$this->addStandardDescFields();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,56 +29,72 @@ trait SeoFieldsTrait
|
||||
protected function addSeoFields($exclude = array())
|
||||
{
|
||||
if (! in_array('url', $exclude))
|
||||
$this->formBuilder
|
||||
->add('url', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('Rewriten URL'),
|
||||
'label_attr' => array(
|
||||
'for' => 'rewriten_url_field',
|
||||
$this->formBuilder->add(
|
||||
'url',
|
||||
'text',
|
||||
[
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Rewriten URL'),
|
||||
'label_attr' => [
|
||||
'for' => 'rewriten_url_field'
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('Use the keyword phrase in your URL.')
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if (! in_array('meta_title', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_title', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('Page Title'),
|
||||
'label_attr' => array(
|
||||
$this->formBuilder->add(
|
||||
'meta_title',
|
||||
'text',
|
||||
[
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Page Title'),
|
||||
'label_attr' => [
|
||||
'for' => 'meta_title',
|
||||
'placeholder' => Translator::getInstance()->trans('Make sure that your title is clear, and contains many of the keywords within the page itself.'),
|
||||
'help' => Translator::getInstance()->trans('The HTML TITLE element is the most important element on your web page.')
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('Make sure that your title is clear, and contains many of the keywords within the page itself.')
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if (! in_array('meta_description', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_description', 'textarea', array(
|
||||
'label' => Translator::getInstance()->trans('Meta Description'),
|
||||
'label_attr' => array(
|
||||
$this->formBuilder->add(
|
||||
'meta_description',
|
||||
'textarea',
|
||||
[
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Meta Description'),
|
||||
'label_attr' => [
|
||||
'for' => 'meta_description',
|
||||
'rows' => 6,
|
||||
'placeholder' => Translator::getInstance()->trans('Make sure it uses keywords found within the page itself.'),
|
||||
'help' => Translator::getInstance()->trans('Keep the most important part of your description in the first 150-160 characters.')
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
],
|
||||
'attr' => [
|
||||
'rows' => 6,
|
||||
'placeholder' => Translator::getInstance()->trans('Make sure it uses keywords found within the page itself.')
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if (! in_array('meta_keywords', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_keywords', 'textarea', array(
|
||||
'label' => Translator::getInstance()->trans('Meta Keywords'),
|
||||
'label_attr' => array(
|
||||
'for' => 'meta_keywords',
|
||||
'rows' => 3,
|
||||
'placeholder' => Translator::getInstance()->trans('Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.'),
|
||||
'help' => Translator::getInstance()->trans('You don\'t need to use commas or other punctuations.')
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
);
|
||||
$this->formBuilder->add(
|
||||
'meta_keywords',
|
||||
'textarea',
|
||||
[
|
||||
'required' => false,
|
||||
'label' => Translator::getInstance()->trans('Meta Keywords'),
|
||||
'label_attr' => [
|
||||
'for' => 'meta_keywords',
|
||||
'help' => Translator::getInstance()->trans('You don\'t need to use commas or other punctuations.')
|
||||
],
|
||||
'attr' => [
|
||||
'rows' => 3,
|
||||
'placeholder' => Translator::getInstance()->trans('Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.')
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -51,6 +51,9 @@ trait StandardDescriptionFieldsTrait
|
||||
'label_attr' => [
|
||||
'for' => 'title_field',
|
||||
'placeholder' => Translator::getInstance()->trans('A descriptive title')
|
||||
],
|
||||
'attr' => [
|
||||
|
||||
]
|
||||
]
|
||||
);
|
||||
@@ -65,11 +68,13 @@ trait StandardDescriptionFieldsTrait
|
||||
'label' => Translator::getInstance()->trans('Summary'),
|
||||
'label_attr' => [
|
||||
'for' => 'summary_field',
|
||||
'rows' => 3,
|
||||
'placeholder' => Translator::getInstance()->trans('Short description text'),
|
||||
'help' => Translator::getInstance()->trans('A short description, used when a summary or an introduction is required')
|
||||
],
|
||||
'attr' => [
|
||||
'rows' => 3,
|
||||
'placeholder' => Translator::getInstance()->trans('Short description text')
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
if (! in_array('description', $exclude))
|
||||
@@ -82,8 +87,10 @@ trait StandardDescriptionFieldsTrait
|
||||
'label' => Translator::getInstance()->trans('Detailed description'),
|
||||
'label_attr' => [
|
||||
'for' => 'detailed_description_field',
|
||||
'rows' => 10,
|
||||
'help' => Translator::getInstance()->trans('The detailed description.')
|
||||
],
|
||||
'attr' => [
|
||||
'rows' => 10
|
||||
]
|
||||
]
|
||||
);
|
||||
@@ -98,9 +105,11 @@ trait StandardDescriptionFieldsTrait
|
||||
'label' => Translator::getInstance()->trans('Conclusion'),
|
||||
'label_attr' => [
|
||||
'for' => 'conclusion_field',
|
||||
'rows' => 3,
|
||||
'placeholder' => Translator::getInstance()->trans('Short additional text'),
|
||||
'help' => Translator::getInstance()->trans('A short text, used when an additional or supplemental information is required.')
|
||||
],
|
||||
'attr' => [
|
||||
'placeholder' => Translator::getInstance()->trans('Short additional text'),
|
||||
'rows' => 3,
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user