Introduced the automatic form fields binding.
This commit is contained in:
@@ -40,13 +40,8 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/document/type/{$documentType}/{$ID}/update"}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="success_url" value="{url path="/admin/document/type/{$documentType}/{$ID}/update"}"}
|
||||
{admin_form_field form=$form name="locale" value="$edit_language_locale"}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -62,43 +57,15 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{form_field form=$form field='file'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="file" id="{$label_attr.for}" name="{$name}" value="" title="{$label}" placeholder="{intl l='File'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{$label}" placeholder="{intl l='Title'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Chapo'}">{$CHAPO}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='postscriptum'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Post Scriptum'}">{$POSTSCRIPTUM}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="file"}
|
||||
{admin_form_field form=$form name="title" value=$TITLE}
|
||||
{admin_form_field form=$form name="chapo" value=$CHAPO}
|
||||
{admin_form_field form=$form name="postscriptum" value=$POSTSCRIPTUM}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control wysiwyg" title="{$label}" placeholder="{intl l='Description'}">{$DESCRIPTION}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
90
templates/backOffice/default/forms/form-field.html
Normal file
90
templates/backOffice/default/forms/form-field.html
Normal file
@@ -0,0 +1,90 @@
|
||||
{form_field form=$form field=$field_name}
|
||||
|
||||
{* 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 $type == 'hidden'}
|
||||
<input type="hidden" id="{$label_attr.for}" name="{$name}" value="{$value}" />
|
||||
{elseif $type == 'checkbox'}
|
||||
|
||||
<div class="checkbox {if $error}has-error{/if}">
|
||||
<label>
|
||||
<input class="{$field_extra_class}" type="checkbox" id="{$label_attr.for}" name="{$name}" value="{$value}" {if $checked}checked="checked"{/if}>
|
||||
{$label} {if $required} <span class="required">*</span>{/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}">
|
||||
|
||||
{admin_form_field_label form=$form name=$field_name label_attr=$label_attr}
|
||||
|
||||
{if $multiple}
|
||||
<span class="label-help-block">{intl l='Use Ctrl+click to select (or deselect) more that one item'}</span>
|
||||
{/if}
|
||||
|
||||
{$lang_code = 0}
|
||||
{if $label_attr.i18n == 'default'}
|
||||
{loop type="lang" name="default-lang" default_only="1"}
|
||||
{$lang_code = $CODE}
|
||||
{$lang_title = $TITLE}
|
||||
<div class="input-group">
|
||||
{/loop}
|
||||
{/if}
|
||||
|
||||
{if $type == 'choice'}
|
||||
<select {if $multiple}multiple{/if} {if $label_attr.size}size="{$label_attr.size}"{/if} {if $required}aria-required="true" required{/if} id="{$label_attr.for}" name="{$name}"class="form-control {$field_extra_class}">
|
||||
{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 {if $label_attr.rows}rows="{$label_attr.rows}"{/if} {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" class="form-control {$field_extra_class}" title="{$label}">{$value}</textarea>
|
||||
|
||||
{elseif $type == 'money'}
|
||||
|
||||
<div class="input-group">
|
||||
<input type="number" {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" />
|
||||
<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}" {if $required}aria-required="true" required{/if} placeholder="{$label_attr.placeholder|default:$label}" id="{$label_attr.for}" name="{$name}" value="{$value}" class="form-control {$field_extra_class}" />
|
||||
{else}
|
||||
<div class="alert alert-danger">{intl l="Unsupported field type '%type' in form-field.html" type=$type}</div>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{if $lang_code}
|
||||
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$lang_code}.png"}" alt="{$lang_title}" /></span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if ! empty($label_attr.help)}
|
||||
<span class="help-block">{$label_attr.help}</span>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{/form_field}
|
||||
8
templates/backOffice/default/forms/form-label.html
Normal file
8
templates/backOffice/default/forms/form-label.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<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>
|
||||
@@ -40,13 +40,8 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}" />
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='locale'}
|
||||
<input type="hidden" name="{$name}" value="{$edit_language_locale}" />
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="success_url" value="{url path="/admin/image/type/{$imageType}/{$ID}/update"}"}
|
||||
{admin_form_field form=$form name="locale" value="$edit_language_locale"}
|
||||
|
||||
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
|
||||
|
||||
@@ -65,43 +60,15 @@
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
{form_field form=$form field='file'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="file" id="{$label_attr.for}" name="{$name}" value="" title="{$label}" placeholder="{intl l='File'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$TITLE}" title="{$label}" placeholder="{intl l='Title'}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Chapo'}">{$CHAPO}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='postscriptum'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control" title="{$label}" placeholder="{intl l='Post Scriptum'}">{$POSTSCRIPTUM}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="file"}
|
||||
{admin_form_field form=$form name="title" value=$TITLE}
|
||||
{admin_form_field form=$form name="chapo" value=$CHAPO}
|
||||
{admin_form_field form=$form name="postscriptum" value=$POSTSCRIPTUM}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<textarea id="{$label_attr.for}" name="{$name}" class="form-control wysiwyg" title="{$label}" placeholder="{intl l='Description'}">{$DESCRIPTION}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="description" value=$DESCRIPTION extra_class="wysiwyg"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -113,8 +80,6 @@
|
||||
page_url = "{url path="/admin/image/type/{$imageType}/{$ID}/update"}"
|
||||
close_url = "{url path="{$redirectUrl}"}"
|
||||
}
|
||||
|
||||
|
||||
</form>
|
||||
{/form}
|
||||
|
||||
|
||||
@@ -16,59 +16,26 @@
|
||||
|
||||
{form_hidden_fields form=$form}
|
||||
|
||||
{form_field form=$form field='success_url'}
|
||||
<input type="hidden" name="{$name}" value="{$closeUrl}">
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="success_url"}
|
||||
|
||||
{* Display error message if exist *}
|
||||
{include file='includes/notifications.html' message=$form_error_message}
|
||||
|
||||
{form_field form=$form field='url'}
|
||||
<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}
|
||||
</label>
|
||||
|
||||
{admin_form_field_label form=$form name='url'}
|
||||
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon">{$url_language|default:{config key="url_site"}}</span>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{intl l='Rewritten URL'}" {if $required} aria-required="true" required{/if} class="form-control" placeholder="{intl l='Use the keyword phrase in your URL.'}">
|
||||
<span class="input-group-addon">{$url_language|default:{config key="url_site"}}/</span>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" value="{$value}" title="{$label}" {if $required} aria-required="true" required{/if} class="form-control" placeholder="{$label_attr.placeholder}">
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
|
||||
{form_field form=$form field='meta_title'}
|
||||
<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}
|
||||
<span class="label-help-block">{intl l='The HTML TITLE element is the most important element on your web page.'}</span>
|
||||
</label>
|
||||
<div class="control-input">
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}"{if $required} aria-required="true" required{/if} title="{$label}" placeholder="{intl l='Make sure that your title is clear, and contains many of the keywords within the page itself.'}">
|
||||
</div>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='meta_description'}
|
||||
<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}
|
||||
<span class="label-help-block">{intl l='Keep the most important part of your description in the first 150-160 characters.'}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="6"{if $required} aria-required="true" required{/if} placeholder="{intl l='Make sure it uses keywords found within the page itself.'}" class="form-control">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='meta_keywords'}
|
||||
<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}
|
||||
<span class="label-help-block">{intl l='You don\'t need to use commas or other punctuations.'}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="3"{if $required} aria-required="true" required{/if} placeholder="{intl l='Don\'t repeat keywords over and over in a row. Rather, put in keyword phrases.'}" class="form-control">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name="meta_title"}
|
||||
{admin_form_field form=$form name="meta_description"}
|
||||
{admin_form_field form=$form name="meta_keywords"}
|
||||
|
||||
{include
|
||||
file = "includes/inner-form-toolbar.html"
|
||||
|
||||
@@ -1,43 +1,6 @@
|
||||
{*
|
||||
The standard description fields, used by many Thelia objects
|
||||
*}
|
||||
{* The standard description fields, used by many Thelia objects *}
|
||||
|
||||
{form_field form=$form field='title'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">{$label} : </label>
|
||||
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="form-control" value="{$value}">
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='chapo'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} :
|
||||
<span class="label-help-block">{intl l="A short description, used when a summary or an introduction is required"}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="3" title="{intl l='Short description'}" placeholder="{intl l='Short description'}" class="form-control">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='description'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} :
|
||||
<span class="label-help-block">{intl l="The detailed description."}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control wysiwyg">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
|
||||
{form_field form=$form field='postscriptum'}
|
||||
<div class="form-group {if $error}has-error{/if}">
|
||||
<label for="{$label_attr.for}" class="control-label">
|
||||
{$label} :
|
||||
<span class="label-help-block">{intl l="A short post-description information"}</span>
|
||||
</label>
|
||||
|
||||
<textarea name="{$name}" id="{$label_attr.for}" rows="3" title="{intl l='Short conclusion'}" placeholder="{intl l='Short conclusion'}" class="form-control">{$value}</textarea>
|
||||
</div>
|
||||
{/form_field}
|
||||
{admin_form_field form=$form name='title'}
|
||||
{admin_form_field form=$form name="chapo"}
|
||||
{admin_form_field form=$form name="description" extra_class="wysiwyg"}
|
||||
{admin_form_field form=$form name="postscriptum"}
|
||||
Reference in New Issue
Block a user