Inital commit
This commit is contained in:
@@ -1,16 +1,29 @@
|
||||
{*
|
||||
{strip}{*
|
||||
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_template : the template style ('standard', or something else)
|
||||
- field_value : the value of the input field, which is used if the form_field value is empty. For radios and checkboxes,
|
||||
the field is supposed to set the checked property if the form checked status is not defined: 0 -> not checked, != 0 -> checked.
|
||||
- field_extra_class : an extra class to add to the input class (see form-field-attributes-standard-renderer.html)
|
||||
- field_no_standard_classes : an extra class to add to the input class (see form-field-attributes-standard-renderer.html)
|
||||
*}
|
||||
|
||||
{* Use the optionnal $field_value parameter if no value is defined *}
|
||||
{if empty($value)}
|
||||
{$value = $field_value}
|
||||
{*
|
||||
Use the optionnal $field_value parameter if no value is defined
|
||||
Do not use empty(), as empty(0), empty("0") are true
|
||||
*}
|
||||
{if $type == 'checkbox' || $type == 'radio'}
|
||||
{* we will not manage the "value" attribute, but the "checked" property. The field is checked if the provied field value is non-zero *}
|
||||
{if ($checked == '' || $checked == null) && isset($field_value) && $field_value !== '' && $field_value !== null}
|
||||
{$checked = $field_value != 0}
|
||||
{/if}
|
||||
{else}
|
||||
{* for other field types, juste manage the "value" attribute. *}
|
||||
{if ($value == '' || $value == null) && isset($field_value) && $field_value !== '' && $field_value !== null}
|
||||
{$value = $field_value}
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{* Synthetize an ID if none was given *}
|
||||
@@ -18,6 +31,17 @@ In addition to the standard form_field block output, this fragment uses the foll
|
||||
{$label_attr.for = "{$form->getName()}-id-{$field_name}"}
|
||||
{/if}
|
||||
|
||||
{* If we have a value key, generates a unique ID based on the value key. *}
|
||||
{if ! empty($value_key)}
|
||||
{$label_attr.for = "{$label_attr.for}_{$value_key}"}
|
||||
{/if}
|
||||
|
||||
{if $field_no_standard_classes}
|
||||
{$standardClass = ''}
|
||||
{else}
|
||||
{$standardClass = 'form-control'}
|
||||
{/if}
|
||||
|
||||
{if $disabled}
|
||||
{$sDisabled = 'disabled'}
|
||||
{/if}
|
||||
@@ -34,18 +58,17 @@ In addition to the standard form_field block output, this fragment uses the foll
|
||||
{$sRequired='aria-required="true" required'}
|
||||
{/if}
|
||||
|
||||
{if $attr_list.placeholder}
|
||||
{$sPlaceholder = "placeholder=\"{$attr_list.placeholder}\""}
|
||||
{/if}
|
||||
|
||||
{if $type == 'hidden'}
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}"
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}" {$attr}
|
||||
{elseif $type == 'checkbox' || $type == 'radio'}
|
||||
id="{$label_attr.for}" name="{$name}" class="{$field_extra_class}" value="{$value}" {if $checked}checked="checked"{/if} {$sDisabled} {$sReadonly} {$sRequired nofilter}
|
||||
id="{$label_attr.for}" name="{$name}" class="{$field_extra_class}" value="{$value}" {if $checked}checked="checked"{/if} {$sDisabled} {$sReadonly} {$sRequired nofilter} {$attr nofilter}
|
||||
{elseif $type == 'choice'}
|
||||
id="{$label_attr.for}" name="{$name} "class="form-control class="{$field_extra_class}" {if $multiple}multiple{/if} {if $lattr_list.size}size="{$lattr_list.size}"{/if} {$sDisabled} {$sReadonly} {$sRequired nofilter}
|
||||
id="{$label_attr.for}" name="{$name}{if $multiple}[]{/if}" class="{$standardClass} {$field_extra_class}" {if $multiple}multiple{/if} {if $attr_list.size}size="{$attr_list.size}"{/if} {$sDisabled} {$sReadonly} {$sRequired nofilter} {$attr nofilter}
|
||||
{elseif $type == 'collection'}
|
||||
id="{$label_attr.for}" name="{$name}[]" class="{$standardClass} {$field_extra_class}" {if $multiple}multiple{/if} {if $attr_list.size}size="{$attr_list.size}"{/if} {$sDisabled} {$sReadonly} {$sRequired nofilter} {$attr nofilter}
|
||||
{elseif $type == 'textarea'}
|
||||
id="{$label_attr.for}" name="{$name}" class="form-control {$field_extra_class}" {if $attr_list.rows}rows="{$attr_list.rows}"{/if} {$sMaxLength nofilter} {$sPlaceholder nofilter} {$sDisabled} {$sReadonly} {$sRequired nofilter}
|
||||
id="{$label_attr.for}" name="{$name}" class="{$standardClass} {$field_extra_class}" {if $attr_list.rows}rows="{$attr_list.rows}"{/if} {$sMaxLength nofilter} {$sDisabled} {$sReadonly} {$sRequired nofilter} {$attr nofilter}
|
||||
{else}
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" {$sMaxLength nofilter} {$sPlaceholder nofilter} {$sDisabled} {$sReadonly} {$sRequired nofilter}
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}" class="{$standardClass} {$field_extra_class}" {$sMaxLength nofilter} {$sDisabled} {$sReadonly} {$sRequired nofilter} {$attr nofilter}
|
||||
{/if}
|
||||
{/strip}
|
||||
@@ -5,22 +5,30 @@ 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)
|
||||
- field_no_standard_classes : an extra class to add to the input class (see form-field-attributes-standard-renderer.html)
|
||||
- show_label : if false, the field label and help line should not be displayed.
|
||||
- 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.
|
||||
*}
|
||||
|
||||
{* Get standard fields attributes *}
|
||||
{capture assign=attributes}
|
||||
{include file="forms/$field_template/form-field-attributes-renderer.html"}
|
||||
{/capture}
|
||||
{capture assign=attributes}{include file="forms/$field_template/form-field-attributes-renderer.html"}{/capture}
|
||||
|
||||
{if empty($value)}
|
||||
{*
|
||||
Use the optionnal $field_value parameter if no value is defined
|
||||
Do not use empty(), as empty(0), empty("0") are true
|
||||
*}
|
||||
{if ($value == '' || $value == null) && isset($field_value) && $field_value !== '' && $field_value !== null}
|
||||
{$value = $field_value}
|
||||
{/if}
|
||||
|
||||
{if $type == 'hidden'}
|
||||
|
||||
<input type="hidden" {$attributes nofilter} />
|
||||
{if $content == ''}
|
||||
<input type="hidden" {$attributes nofilter} />
|
||||
{else}
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{elseif $type == 'checkbox'}
|
||||
|
||||
@@ -33,11 +41,17 @@ fragment uses the following additional variables :
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
{if $show_label}
|
||||
{form_error field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
{/if}
|
||||
</label>
|
||||
|
||||
{if $show_label && ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
{elseif $type == 'radio'}
|
||||
@@ -51,28 +65,36 @@ fragment uses the following additional variables :
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{form_error form=$form field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
{if $show_label}
|
||||
{form_error field=$field_name}
|
||||
<br />
|
||||
<span class="error">{$message}</span>
|
||||
{/form_error}
|
||||
{/if}
|
||||
</label>
|
||||
|
||||
{if $show_label && ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</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}
|
||||
{if $show_label}
|
||||
<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>
|
||||
{form_error 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 $multiple && $show_label}
|
||||
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one item'}</span>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{if $content == ''}
|
||||
@@ -81,8 +103,8 @@ fragment uses the following additional variables :
|
||||
|
||||
<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}
|
||||
<option value="{$choice->value}" {if (is_array($value) && in_array($choice->value, $value)) || $choice->value == $value}selected="selected"{/if}>{$choice->label}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
|
||||
{elseif $type == 'textarea'}
|
||||
@@ -92,20 +114,29 @@ fragment uses the following additional variables :
|
||||
{elseif $type == 'money'}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" {$attributes nofilter} />
|
||||
<input type="number" step="any" {$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']}
|
||||
{$text_types = ['text', 'password', 'number', 'integer', 'time', 'date', 'datetime', 'email', 'url', 'file']}
|
||||
{$thelia_types = ['country_id', 'currency_id', 'customer_id', 'customer_title_id', 'lang_id', 'category_id', 'product_id', 'product_sale_elements_id', 'folder_id', 'content_id', 'tax_id', 'tax_rule_id']}
|
||||
|
||||
{if in_array($type, $text_types)}
|
||||
{if $type == 'integer' || $type == 'money'}{$type='number'}{/if}
|
||||
{if $type == 'integer'}{$type='number'}{/if}
|
||||
|
||||
<input type="{$type}" {$attributes nofilter} />
|
||||
{elseif in_array($type, $thelia_types)}
|
||||
{if $attr and empty($attr.autocomplete)}
|
||||
<input type="number" {$attributes nofilter} />
|
||||
{else}
|
||||
{* You should implement the auto completion *}
|
||||
<input type="hidden" {$attributes nofilter} />
|
||||
<input type="text" data-widget="{$type}" data-rel="#{$label_attr.for}" class="form-control" />
|
||||
{/if}
|
||||
{else}
|
||||
<div class="alert alert-danger">{intl l="Unsupported field type '%type' in form-field.html" type=$type}</div>
|
||||
<div class="alert alert-danger">{intl l="Unsupported field type '%type' in form-field.html" type={$type}}</div>
|
||||
{/if}
|
||||
|
||||
{/if}
|
||||
@@ -113,8 +144,8 @@ fragment uses the following additional variables :
|
||||
{$content nofilter}
|
||||
{/if}
|
||||
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{if $show_label && ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help nofilter}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user