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,
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{admin_form_field form=$form name="success_url" value={url path="/admin/brand"}}
|
||||
{admin_form_field form=$form name="locale" value={$edit_language_locale}}
|
||||
{render_form_field form=$form field="success_url" value={url path="/admin/brand"}}
|
||||
{render_form_field form=$form field="locale" value={$edit_language_locale}}
|
||||
|
||||
{if $form_error}
|
||||
<div class="alert alert-danger">{$form_error_message}</div>
|
||||
@@ -82,27 +82,17 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
{admin_form_field form=$form name="visible"}
|
||||
{render_form_field form=$form field="visible"}
|
||||
|
||||
{form_field form=$form field='logo_image_id'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
{admin_form_field_label form=$form name='logo_image_id'}
|
||||
|
||||
<select id="{$label_attr.for}" {if $required}aria-required="true" required{/if} name="{$name}" class="form-control brand-image-selector">
|
||||
<option value="">{intl l="No logo image"}</option>
|
||||
|
||||
{loop name="brand-images" type="image" brand=$ID width="90" height="90" resize_mode="crop"}
|
||||
<option value="{$ID}" data-img-src="{$IMAGE_URL}" {if $LOGO_IMAGE_ID == $ID}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
|
||||
{if $label_attr.help}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
{custom_render_form_field form=$form field='logo_image_id'}
|
||||
<select {form_field_attributes form=$form field='logo_image_id' extra_class='brand-image-selector'} >
|
||||
<option value="">{intl l="No logo image"}</option>
|
||||
|
||||
{loop name="brand-images" type="image" brand=$ID width="90" height="90" resize_mode="crop"}
|
||||
<option value="{$ID}" data-img-src="{$IMAGE_URL}" {if $LOGO_IMAGE_ID == $ID}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{/custom_render_form_field}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -190,12 +190,26 @@
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{admin_form_field form=$form name="locale" value=$LOCALE}
|
||||
{render_form_field form=$form field="locale" value=$LOCALE}
|
||||
{/loop}
|
||||
|
||||
{admin_form_field form=$form name="success_url" value={url path='/admin/brand/update/_ID_'}}
|
||||
{admin_form_field form=$form name="title"}
|
||||
{admin_form_field form=$form name="visible"}
|
||||
{render_form_field form=$form field="success_url" value={url path='/admin/brand/update/_ID_'}}
|
||||
|
||||
{custom_render_form_field form=$form field="title"}
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
{* Switch edition to the current locale *}
|
||||
<input type="hidden" name="edit_language_id" value="{$ID}" />
|
||||
|
||||
{render_form_field field="locale" value=$LOCALE}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="text" {$form_field_attributes form=$form field="title" template="toto"}>
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.png"}" alt="{$TITLE}" /></span>
|
||||
</div>
|
||||
{/loop}
|
||||
{/custom_render_form_field}
|
||||
|
||||
{render_form_field form=$form field="visible"}
|
||||
|
||||
{module_include location='brand_create_form'}
|
||||
|
||||
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{admin_form_field form=$form name="success_url" value="{url path="/admin/document/type/{$documentType}/{$ID}/update"}"}
|
||||
{admin_form_field form=$form name="locale" value="$edit_language_locale"}
|
||||
{render_form_field form=$form field="success_url" value="{url path="/admin/document/type/{$documentType}/{$ID}/update"}"}
|
||||
{render_form_field form=$form field="locale" value="$edit_language_locale"}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -57,15 +57,15 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{admin_form_field form=$form name="file"}
|
||||
{admin_form_field form=$form name="title" value=$TITLE}
|
||||
{admin_form_field form=$form name="chapo" value=$CHAPO}
|
||||
{admin_form_field form=$form name="postscriptum" value=$POSTSCRIPTUM}
|
||||
{render_form_field form=$form field="file"}
|
||||
{render_form_field form=$form field="title" value=$TITLE}
|
||||
{render_form_field form=$form field="chapo" value=$CHAPO}
|
||||
{render_form_field form=$form field="postscriptum" value=$POSTSCRIPTUM}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{admin_form_field form=$form name="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
{render_form_field form=$form field="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
{*
|
||||
This file defines the standard fields attributes, depending on input types.
|
||||
|
||||
In addition to the standard form_field block output, this fragment uses the following additional variables :
|
||||
|
||||
- field_template : the template style ('standard', or somethingelse)
|
||||
- field_value : the value of the input field, which is used if the form_field value is empty.
|
||||
- field_extra_class : an extra class to add to the input class (see form-field-attributes-standard-renderer.html)
|
||||
*}
|
||||
|
||||
{if $type == 'hidden'}
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}"
|
||||
{elseif $type == 'checkbox' || $type == 'radio'}
|
||||
class="{$field_extra_class}" type="checkbox" id="{$label_attr.for}" name="{$name}" value="{$value}" {if $checked}checked="checked"{/if}
|
||||
{elseif $type == 'choice'}
|
||||
{if $multiple}multiple{/if} {if $lattr_list.size}size="{$lattr_list.size}"{/if} {if $required}aria-required="true" required{/if} id="{$label_attr.for}" name="{$name}"class="form-control class="{$field_extra_class}"
|
||||
{elseif $type == 'textarea'}
|
||||
{if $attr_list.rows}rows="{$attr_list.rows}"{/if} {if $required}aria-required="true" required{/if} placeholder="{$attr_list.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" class="form-control {$field_extra_class}" title="{$label}"
|
||||
{else}
|
||||
{if $required}aria-required="true" required{/if} placeholder="{$attr_list.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}"
|
||||
{/if}
|
||||
@@ -0,0 +1,126 @@
|
||||
{*
|
||||
This file bind a form field to an HTML representation. In addition to the standard form_field block output, this
|
||||
fragment uses the following additional variables :
|
||||
|
||||
- field_template : the template style ('standard', or somethingelse)
|
||||
- field_value : the value of the input field, which is used if the form_field value is empty.
|
||||
- field_extra_class : an extra class to add to the input class (see form-field-attributes-standard-renderer.html)
|
||||
- content : if this variable is not empty, we assume that it contains the input field definition. Used by the
|
||||
custom_render_form_field block to pass a custom representation of the input field.
|
||||
*}
|
||||
|
||||
{* Use the optionnal $field_value parameter if no value is defined *}
|
||||
{if empty($value)}
|
||||
{$value = $field_value}
|
||||
{/if}
|
||||
|
||||
{* Synthetize an ID if none was given *}
|
||||
{if empty({$label_attr.for})}
|
||||
{$label_attr.for = "id-{$field_name}"}
|
||||
{/if}
|
||||
|
||||
{* Get standard fields attributes *}
|
||||
{capture assign=attributes}
|
||||
{include file="forms/form-field-attributes-$field_template-renderer.html"}
|
||||
{/capture}
|
||||
|
||||
{if $type == 'hidden'}
|
||||
|
||||
<input type="hidden" {$attributes nofilter} />
|
||||
|
||||
{elseif $type == 'checkbox'}
|
||||
|
||||
<div class="checkbox {if $error}has-error{/if}">
|
||||
<label>
|
||||
{if $content == ''}
|
||||
<input type="checkbox" {$attributes nofilter}>
|
||||
{$label} {if $required} <span class="required">*</span>{/if}
|
||||
{else}
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{elseif $type == 'radio'}
|
||||
|
||||
<div class="radio {if $error}has-error{/if}">
|
||||
<label>
|
||||
{if $content == ''}
|
||||
<input type="radio" {$attributes nofilter}>
|
||||
{$label} {if $required} <span class="required">*</span>{/if}
|
||||
{else}
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} {if $required} <span class="required">*</span>{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
|
||||
{if $multiple}
|
||||
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one item'}</span>
|
||||
{/if}
|
||||
|
||||
{if $content == ''}
|
||||
|
||||
{if $type == 'choice'}
|
||||
|
||||
<select {$attributes nofilter}>
|
||||
{foreach $choices as $choice}
|
||||
<option value="{$choice->value}" {if (is_array($value) && in_array($choice->value, $value)) || $choice->value == $value}selected="selected"{/if}>{$choice->label}
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
{elseif $type == 'textarea'}
|
||||
|
||||
<textarea {$attributes nofilter}>{$value}</textarea>
|
||||
|
||||
{elseif $type == 'money'}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" {$attributes nofilter} />
|
||||
<span class="input-group-addon">{loop name="input.addon" type="currency" default_only="true"}{$SYMBOL}{/loop}</span>
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
{$text_types = ['text', 'password', 'number', 'money', 'integer', 'time', 'date', 'datetime', 'email', 'url', 'file']}
|
||||
|
||||
{if in_array($type, $text_types)}
|
||||
{if $type == 'integer' || $type == 'money'}{$type='number'}{/if}
|
||||
|
||||
<input type="{$type}" {$attributes nofilter} />
|
||||
{else}
|
||||
<div class="alert alert-danger">{intl l="Unsupported field type '%type' in form-field.html" type=$type}</div>
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
{else}
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,90 +0,0 @@
|
||||
{form_field form=$form field=$field_name}
|
||||
|
||||
{* Use the optionnal $field_value parameter if no value is defined *}
|
||||
{if empty($value)}
|
||||
{$value = $field_value}
|
||||
{/if}
|
||||
|
||||
{* Synthetize an ID if none was given *}
|
||||
{if empty({$label_attr.for})}
|
||||
{$label_attr.for = "id-{$field_name}"}
|
||||
{/if}
|
||||
|
||||
{if $type == 'hidden'}
|
||||
<input type="hidden" id="{$label_attr.for}" name="{$name}" value="{$value}" />
|
||||
{elseif $type == 'checkbox'}
|
||||
|
||||
<div class="checkbox {if $error}has-error{/if}">
|
||||
<label>
|
||||
<input class="{$field_extra_class}" type="checkbox" id="{$label_attr.for}" name="{$name}" value="{$value}" {if $checked}checked="checked"{/if}>
|
||||
{$label} {if $required} <span class="required">*</span>{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
{admin_form_field_label form=$form name=$field_name label_attr=$label_attr}
|
||||
|
||||
{if $multiple}
|
||||
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one item'}</span>
|
||||
{/if}
|
||||
|
||||
{$lang_code = 0}
|
||||
{if $label_attr.i18n == 'default'}
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
{$lang_code = $CODE}
|
||||
{$lang_title = $TITLE}
|
||||
<div class="input-group">
|
||||
{/loop}
|
||||
{/if}
|
||||
|
||||
{if $type == 'choice'}
|
||||
<select {if $multiple}multiple{/if} {if $label_attr.size}size="{$label_attr.size}"{/if} {if $required}aria-required="true" required{/if} id="{$label_attr.for}" name="{$name}"class="form-control {$field_extra_class}">
|
||||
{foreach $choices as $choice}
|
||||
<option value="{$choice->value}" {if (is_array($value) && in_array($choice->value, $value)) || $choice->value == $value}selected="selected"{/if}>{$choice->label}
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
{elseif $type == 'textarea'}
|
||||
|
||||
<textarea {if $label_attr.rows}rows="{$label_attr.rows}"{/if} {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" class="form-control {$field_extra_class}" title="{$label}">{$value}</textarea>
|
||||
|
||||
{elseif $type == 'money'}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" />
|
||||
<span class="input-group-addon">{loop name="input.addon" type="currency" default_only="true"}{$SYMBOL}{/loop}</span>
|
||||
</div>
|
||||
|
||||
{else}
|
||||
|
||||
{$text_types = ['text', 'password', 'number', 'money', 'integer', 'time', 'date', 'datetime', 'email', 'url', 'file']}
|
||||
|
||||
{if in_array($type, $text_types)}
|
||||
{if $type == 'integer' || $type == 'money'}{$type='number'}{/if}
|
||||
|
||||
|
||||
<input type="{$type}" {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" />
|
||||
{else}
|
||||
<div class="alert alert-danger">{intl l="Unsupported field type '%type' in form-field.html" type=$type}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{if $lang_code}
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$lang_code}.png"}" alt="{$lang_title}" /></span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/form_field}
|
||||
@@ -1,8 +0,0 @@
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} {if $required} <span class="required">*</span>{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
</label>
|
||||
@@ -40,8 +40,8 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{admin_form_field form=$form name="success_url" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}"}
|
||||
{admin_form_field form=$form name="locale" value="$edit_language_locale"}
|
||||
{render_form_field form=$form field="success_url" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}"}
|
||||
{render_form_field form=$form field="locale" value="$edit_language_locale"}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -60,15 +60,15 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{admin_form_field form=$form name="file"}
|
||||
{admin_form_field form=$form name="title" value=$TITLE}
|
||||
{admin_form_field form=$form name="chapo" value=$CHAPO}
|
||||
{admin_form_field form=$form name="postscriptum" value=$POSTSCRIPTUM}
|
||||
{render_form_field form=$form field="file"}
|
||||
{render_form_field form=$form field="title" value=$TITLE}
|
||||
{render_form_field form=$form field="chapo" value=$CHAPO}
|
||||
{render_form_field form=$form field="postscriptum" value=$POSTSCRIPTUM}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{admin_form_field form=$form name="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
{render_form_field form=$form field="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -71,24 +71,15 @@
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='brand_id'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
{custom_render_form_field form=$form field='brand_id'}
|
||||
<select {$field_attributes}>
|
||||
<option value="0">{intl l="No brand"}</option>
|
||||
|
||||
{admin_form_field_label form=$form name='brand_id'}
|
||||
|
||||
<select id="{$label_attr.for}" {if $required}aria-required="true" required{/if} name="{$name}" class="form-control">
|
||||
<option value="0">{intl l="No brand"}</option>
|
||||
|
||||
{loop name="brand-list" type="brand" visible="*"}
|
||||
<option value="{$ID}" {if $BRAND_ID == $ID}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/form_field}
|
||||
{loop name="brand-list" type="brand" visible="*"}
|
||||
<option value="{$ID}" {if $BRAND_ID == $ID}selected="selected"{/if}>{$TITLE}</option>
|
||||
{/loop}
|
||||
</select>
|
||||
{/custom_render_form_field}
|
||||
|
||||
{form_field form=$form field='visible'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
@@ -16,26 +16,21 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{admin_form_field form=$form name="success_url"}
|
||||
{render_form_field form=$form field="success_url"}
|
||||
|
||||
{* Display error message if exist *}
|
||||
{include file='includes/notifications.html' message=$form_error_message}
|
||||
|
||||
{form_field form=$form field='url'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
|
||||
{admin_form_field_label form=$form name='url'}
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{$url_language|default:{config key="url_site"}}/</span>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{$label}" {if $required} aria-required="true" required{/if} class="form-control" placeholder="{$label_attr.placeholder}">
|
||||
</div>
|
||||
{custom_render_form_field form=$form field='url'}
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{$url_language|default:{config key="url_site"}}/</span>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{$label}" {if $required} aria-required="true" required{/if} class="form-control" placeholder="{$label_attr.placeholder}">
|
||||
</div>
|
||||
{/form_field}
|
||||
{/custom_render_form_field}
|
||||
|
||||
{admin_form_field form=$form name="meta_title"}
|
||||
{admin_form_field form=$form name="meta_description"}
|
||||
{admin_form_field form=$form name="meta_keywords"}
|
||||
{render_form_field form=$form field="meta_title"}
|
||||
{render_form_field form=$form field="meta_description"}
|
||||
{render_form_field form=$form field="meta_keywords"}
|
||||
|
||||
{include
|
||||
file = "includes/inner-form-toolbar.html"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{* The standard description fields, used by many Thelia objects *}
|
||||
|
||||
{admin_form_field form=$form name='title'}
|
||||
{admin_form_field form=$form name="chapo"}
|
||||
{admin_form_field form=$form name="description" extra_class="wysiwyg"}
|
||||
{admin_form_field form=$form name="postscriptum"}
|
||||
{render_form_field form=$form field='title'}
|
||||
{render_form_field form=$form field="chapo"}
|
||||
{render_form_field form=$form field="description" extra_class="wysiwyg"}
|
||||
{render_form_field form=$form field="postscriptum"}
|
||||
Reference in New Issue
Block a user