Fixed minor typos, improved field attributes generation
This commit is contained in:
@@ -49,11 +49,10 @@ trait StandardDescriptionFieldsTrait
|
|||||||
'required' => true,
|
'required' => true,
|
||||||
'label' => Translator::getInstance()->trans('Title'),
|
'label' => Translator::getInstance()->trans('Title'),
|
||||||
'label_attr' => [
|
'label_attr' => [
|
||||||
'for' => 'title_field',
|
'for' => 'title_field'
|
||||||
'placeholder' => Translator::getInstance()->trans('A descriptive title')
|
|
||||||
],
|
],
|
||||||
'attr' => [
|
'attr' => [
|
||||||
|
'placeholder' => Translator::getInstance()->trans('A descriptive title')
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -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)
|
- 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'}
|
{if $type == 'hidden'}
|
||||||
id="{$label_attr.for}" name="{$name}" value="{$value}"
|
id="{$label_attr.for}" name="{$name}" value="{$value}"
|
||||||
{elseif $type == 'checkbox' || $type == 'radio'}
|
{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'}
|
{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'}
|
{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}
|
{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}
|
{/if}
|
||||||
|
|||||||
@@ -9,16 +9,6 @@ fragment uses the following additional variables :
|
|||||||
custom_render_form_field block to pass a custom representation of the input field.
|
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 *}
|
{* Get standard fields attributes *}
|
||||||
{capture assign=attributes}
|
{capture assign=attributes}
|
||||||
{include file="forms/form-field-attributes-$field_template-renderer.html"}
|
{include file="forms/form-field-attributes-$field_template-renderer.html"}
|
||||||
|
|||||||
Reference in New Issue
Block a user