Fixed minor typos, improved field attributes generation

This commit is contained in:
Franck Allimant
2014-07-03 16:54:42 +02:00
parent af5e0bde23
commit 7576b9990b
3 changed files with 32 additions and 17 deletions

View File

@@ -49,11 +49,10 @@ trait StandardDescriptionFieldsTrait
'required' => true,
'label' => Translator::getInstance()->trans('Title'),
'label_attr' => [
'for' => 'title_field',
'placeholder' => Translator::getInstance()->trans('A descriptive title')
'for' => 'title_field'
],
'attr' => [
'placeholder' => Translator::getInstance()->trans('A descriptive title')
]
]
);

View File

@@ -8,14 +8,40 @@ In addition to the standard form_field block output, this fragment uses the foll
- 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}
{$disabled = 'disabled'}
{/if}
{if $disabled}
{$readonly = 'readonly'}
{/if}
{if $required}
{$required='aria-required="true" required'}
{/if}
{if $attr_list.placeholder}
{$placeholder = "placeholder=\"{$attr_list.placeholder}\""}
{/if}
{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}
id="{$label_attr.for}" name="{$name}" class="{$field_extra_class}" value="{$value}" {if $checked}checked="checked"{/if} {$disabled} {$readonly} {$required}
{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}"
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} {$disabled} {$readonly} {$required}
{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}"
id="{$label_attr.for}" name="{$name}" class="form-control {$field_extra_class}" {if $attr_list.rows}rows="{$attr_list.rows}"{/if} {$placeholder nofilter} {$disabled} {$readonly} {$required}
{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}"
id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" {$placeholder nofilter} {$disabled} {$readonly} {$required}
{/if}

View File

@@ -9,16 +9,6 @@ fragment uses the following additional variables :
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"}