Template fragments are now in a subdirectory
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
{*
|
||||
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)
|
||||
*}
|
||||
|
||||
{* 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 $disabled}
|
||||
{$sDisabled = 'disabled'}
|
||||
{/if}
|
||||
|
||||
{if $read_only}
|
||||
{$sRead_only = 'readonly'}
|
||||
{/if}
|
||||
|
||||
{if $max_length}
|
||||
{$sMaxLength = "maxlength=\"{$max_length}\""}
|
||||
{/if}
|
||||
|
||||
{if $required}
|
||||
{$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}"
|
||||
{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}
|
||||
{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}
|
||||
{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}
|
||||
{else}
|
||||
id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" {$sMaxLength nofilter} {$sPlaceholder nofilter} {$sDisabled} {$sReadonly} {$sRequired}
|
||||
{/if}
|
||||
@@ -0,0 +1,116 @@
|
||||
{*
|
||||
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.
|
||||
*}
|
||||
|
||||
{* Get standard fields attributes *}
|
||||
{capture assign=attributes}
|
||||
{include file="forms/$field_template/form-field-attributes-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}
|
||||
Reference in New Issue
Block a user