{* 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_id : the ID of the input field. Override the ID defined in the form definition - 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} {* see form-field-attributes-renderer.html *} {* Use the provided id if any *} {if (!isset($label_attr.for))} {$label_attr.for = ""} {/if} {if (! empty($field_id))} {$label_attr.for = $field_id} {elseif empty({$label_attr.for|default:null})} {* Synthetize an ID if none was given *} {$label_attr.for = "{$form->getName()}-id-{$field_name}"} {/if} {* 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'} {if $content == ''} {else} {$content nofilter} {/if} {elseif $type == 'checkbox'}
{if $show_label && ! empty($label_attr.help)} {$label_attr.help} {/if}
{elseif $type == "radio"}
{if $show_label && ! empty($label_attr.help)} {$label_attr.help} {/if}
{else}
{if $show_label} {if $multiple && $show_label} {intl l='Use Ctrl+click to select (or deselect) more that one item'} {/if} {/if} {if $content == ''} {if $type == "choice"} {elseif $type == "textarea"} {elseif $type == 'money'}
{loop name="input.addon" type="currency" default_only="true"}{$SYMBOL}{/loop}
{else} {$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='number'}{/if} {elseif in_array($type, $thelia_types)} {if $attr and empty($attr.autocomplete)} {else} {* You should implement the auto completion *} {/if} {else}
{intl l="Unsupported field type '%type' in form-field.html" type={$type}}
{/if} {/if} {else} {$content nofilter} {/if} {if $show_label && ! empty($label_attr.help)} {$label_attr.help nofilter} {/if}
{/if}