Working :

- Add label information in Form file
- Refactor to bootstrap3
This commit is contained in:
mespeche
2013-09-06 12:55:53 +02:00
parent fed1795e93
commit 56de467362
4 changed files with 244 additions and 248 deletions

View File

@@ -40,11 +40,19 @@ class MessageCreationForm extends BaseForm
$this->formBuilder
->add("name", "text", array(
"constraints" => $name_constraints
"constraints" => $name_constraints,
"label" => "Name *",
"label_attr" => array(
"for" => "name"
)
))
->add("title", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => "Purpose *",
"label_attr" => array(
"for" => "purpose"
)
))
->add("locale", "hidden", array(

View File

@@ -33,13 +33,43 @@ class MessageModificationForm extends BaseForm
{
$this->formBuilder
->add("id" , "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
->add("name" , "text" , array("constraints" => array(new NotBlank())))
->add("secured" , "text" , array())
->add("name" , "text" , array(
"constraints" => array(new NotBlank()),
"label" => "Name *",
"label_attr" => array(
"for" => "name"
)
))
->add("secured" , "text" , array(
"label" => "Prevent mailing template modification or deletion, except for super-admin"
))
->add("locale" , "text" , array())
->add("title" , "text" , array("constraints" => array(new NotBlank())))
->add("subject" , "text" , array("constraints" => array(new NotBlank())))
->add("html_message" , "text" , array())
->add("text_message" , "text" , array())
->add("title" , "text" , array(
"constraints" => array(new NotBlank()),
"label" => "Title *",
"label_attr" => array(
"for" => "title"
)
))
->add("subject" , "text" , array(
"constraints" => array(new NotBlank()),
"label" => "Message subject *",
"label_attr" => array(
"for" => "subject"
)
))
->add("html_message" , "text" , array(
"label" => "HTML Message",
"label_attr" => array(
"for" => "html_message"
)
))
->add("text_message" , "text" , array(
"label" => "Text Message",
"label_attr" => array(
"for" => "text_message"
)
))
;
}

View File

@@ -27,127 +27,85 @@
</div>
<div class="form-container">
<div class="form-horizontal col-md-12">
<div class="col-md-12">
{form name="thelia.admin.message.modification"}
<form method="POST" action="{url path='/admin/configuration/messages/save'}" {form_enctype form=$form}>
<fieldset>
{* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" />
{* Be sure to get the message ID, even if the form could not be validated *}
<input type="hidden" name="message_id" value="{$message_id}" />
{include file="includes/inner-form-toolbar.html"}
{include file="includes/inner-form-toolbar.html"}
{form_hidden_fields form=$form}
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" />
{/form_field}
{form_field form=$form field='success_url'}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages'}" />
{/form_field}
{form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
{/form_field}
{form_field form=$form field='id'}
<input type="hidden" name="{$name}" value="{$value|htmlspecialchars}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{{$edit_language_locale}}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{{$edit_language_locale}}" />
{/form_field}
{if #form_error}<div class="alert alert-block alert-error">#form_error_message</div>{/if}
{if #form_error}<div class="alert alert-danger">#form_error_message</div>{/if}
{form_field form=$form field='name'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="form-control">
</div>
{/form_field}
{form_field form=$form field='secured'}
<div class="checkbox {if $error}has-error{/if}">
<label>
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="{$label}"}
</label>
</div>
{/form_field}
<div class="control-group">
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$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|htmlspecialchars}">
</div>
{/form_field}
<label class="control-label">
{intl l='Name *'}
</label>
{form_field form=$form field='subject'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" required="required" title="{intl l='Subject'}" placeholder="{intl l='Subject'}" class="form-control" value="{$value|htmlspecialchars}">
</div>
{/form_field}
<div class="controls">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value|htmlspecialchars}" title="{intl l='Variable name'}" placeholder="{intl l='Variable name'}" class="input-block-level">
</span>
{/form_field}
</div>
</div>
{form_field form=$form field='html_message'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl l="{$label}"} :
<span class="label-help-block">{intl l="The mailing template in HTML format."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div>
{/form_field}
<div class="control-group">
<label class="control-label">
{intl l='Secured'}
</label>
{form_field form=$form field='text_message'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">
{intl l="{$label}"} :
<span class="label-help-block">{intl l="The mailing template in text-only format."}</span>
</label>
<textarea name="{$name}" id="{$label_attr.for}" rows="10" class="form-control">{$value|htmlspecialchars}</textarea>
</div>
{/form_field}
<div class="controls">
{form_field form=$form field='secured'}
<span {if $error}class="error"{/if}>
<label class="checkbox">
<input type="checkbox" name="{$name}" value="1" {if $value == 1}checked="checked"{/if}>
{intl l="Prevent mailing template modification or deletion, except for super-admin"}
</label>
</span>
{/form_field}
</div>
</div>
{form_field form=$form field='title'}
<div class="control-group">
<label class="control-label">
{intl l='Title *'}
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" required="required" title="{intl l='Title'}" placeholder="{intl l='Title'}" class="input-block-level" value="{$value|htmlspecialchars}">
</span>
</div>
</div>
{/form_field}
{form_field form=$form field='subject'}
<div class="control-group">
<label class="control-label">
{intl l='Message subject *'}
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<input type="text" name="{$name}" required="required" title="{intl l='Subject'}" placeholder="{intl l='Subject'}" class="input-block-level" value="{$value|htmlspecialchars}">
</span>
</div>
</div>
{/form_field}
{form_field form=$form field='html_message'}
<div class="control-group">
<label class="control-label">
{intl l='HTML Message'}
<span class="label-help-block">{intl l="The mailing template in HTML format."}</span>
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="10" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div>
{/form_field}
{form_field form=$form field='text_message'}
<div class="control-group">
<label class="control-label">
{intl l='Text Message'}
<span class="label-help-block">{intl l="The mailing template in text-only format."}</span>
</label>
<div class="controls">
<span {if $error}class="error"{/if}>
<textarea name="{$name}" rows="10" class="input-block-level">{$value|htmlspecialchars}</textarea>
</span>
</div>
</div>
{/form_field}
<div class="control-group">
<div class="controls">
<p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
</div>
</div>
</fieldset>
<div class="form-group">
<p>{intl l='Message created on %date_create. Last modification: %date_change' date_create="{format_date date=$CREATE_DATE}" date_change="{format_date date=$UPDATE_DATE}"}}</p>
</div>
</form>
{/form}
</div>

View File

@@ -31,62 +31,65 @@
{/loop}
</caption>
<tr>
<th>{intl l="Purpose"}</th>
<th>{intl l="Name"}</th>
<thead>
<tr>
<th>{intl l="Purpose"}</th>
<th>{intl l="Name"}</th>
{module_include location='messages_table_header'}
{module_include location='messages_table_header'}
<th>&nbsp;</th>
</tr>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"}
<tr>
{loop name="mailing-templates" type="message" secured="*" backend_context="1" lang="$lang_id"}
<tr>
<td>{$TITLE}</td>
<td>{$TITLE}</td>
<td>
{if ! $SECURED}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a>
{/loop}
{elseloop rel="can_change"}
<td>
{if ! $SECURED}
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}">{$NAME}</a>
{/loop}
{elseloop rel="can_change"}
{$NAME}
{/elseloop}
{else}
{$NAME}
{/elseloop}
{else}
{$NAME}
{/if}
</td>
{/if}
</td>
{module_include location='messages_table_row'}
{module_include location='messages_table_row'}
<td class="actions">
{if ! $SECURED}
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a class="btn btn-default btn-xs message-change" title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
<td class="actions">
{if ! $SECURED}
<div class="btn-group">
{loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.messages.change"}
<a class="btn btn-default btn-xs message-change" title="{intl l='Change this mailing template'}" href="{url path='/admin/configuration/messages/update' message_id="$ID"}"><i class="glyphicon glyphicon-edit"></i></a>
{/loop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"}
<a class="btn btn-default btn-xs message-delete" title="{intl l='Delete this mailing template'}" href="#delete_message_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
{else}
<i title="{intl l='This mailing template could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
{/if}
</td>
</tr>
{/loop}
{elseloop rel="mailing-templates"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="No mailing template has been created yet. Click the + button to create one."}
</div>
</td>
</tr>
{/elseloop}
{loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.configuration.messages.delete"}
<a class="btn btn-default btn-xs message-delete" title="{intl l='Delete this mailing template'}" href="#delete_message_dialog" data-id="{$ID}" data-toggle="modal"><i class="glyphicon glyphicon-trash"></i></a>
{/loop}
</div>
{else}
<i title="{intl l='This mailing template could not be changed.'}" class="glyphicon glyphicon-ban-circle"></i>
{/if}
</td>
</tr>
{/loop}
{elseloop rel="mailing-templates"}
<tr>
<td colspan="3">
<div class="alert alert-info">
{intl l="No mailing template has been created yet. Click the + button to create one."}
</div>
</td>
</tr>
{/elseloop}
</tbody>
</table>
</div>
</form>
@@ -101,110 +104,107 @@
{* Adding a new message *}
<div class="modal hide fade" id="add_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="add_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new mailing template"}</h3>
</div>
{form name="thelia.admin.message.creation"}
<form method="POST" action="{url path='/admin/configuration/messages/create'}" {form_enctype form=$form}>
{form_hidden_fields form=$form}
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created message ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages/update' message_id='_ID_'}" />
{/form_field}
{* We do not allow users to create secured messages from here *}
{form_field form=$form field='secured'}
<input type="hidden" name="{$name}" value="0" />
{/form_field}
<div class="modal-body">
{if #form_error}<div class="alert alert-block alert-error" id="add_message_dialog_error">#form_error_message</div>{/if}
<div class="control-group">
<label class="control-label">
{intl l='Name *'}
</label>
<div class="controls">
{form_field form=$form field='name'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template name'}" placeholder="{intl l='Mailing template name'}" class="input-block-level">
</span>
{/form_field}
</div>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Create a new mailing template"}</h3>
</div>
<div class="control-group">
<label class="control-label">
{intl l='Purpose *'}
</label>
{form name="thelia.admin.message.creation"}
<form method="POST" action="{url path='/admin/configuration/messages/create'}" {form_enctype form=$form}>
<div class="controls">
{loop type="lang" name="default-lang" default_only="1"}
{form_hidden_fields form=$form}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
{form_field form=$form field='success_url'}
{* on success, redirect to the edition page, _ID_ is replaced with the created message ID, see controller *}
<input type="hidden" name="{$name}" value="{url path='/admin/configuration/messages/update' message_id='_ID_'}" />
{/form_field}
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
{* We do not allow users to create secured messages from here *}
<div class="input-group input-block-level">
{form_field form=$form field='title'}
<span {if $error}class="error"{/if}>
<input type="text" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template purpose'}" placeholder="{intl l='Mailing template purpose'}" class="input-block-level">
</span>
{form_field form=$form field='secured'}
<input type="hidden" name="{$name}" value="0" />
{/form_field}
<div class="modal-body">
{if #form_error}<div class="alert alert-danger" id="add_message_dialog_error">#form_error_message</div>{/if}
{form_field form=$form field='name'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template name'}" placeholder="{intl l='Mailing template name'}" class="form-control">
</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">{intl l="{$label}"} : </label>
{loop type="lang" name="default-lang" default_only="1"}
{* Switch edition to the current locale *}
<input type="hidden" name="edit_language_id" value="{$ID}" />
<div class="input-group">
<input type="text" id="{$label_attr.for}" required="required" name="{$name}" value="{$value}" title="{intl l='Mailing template purpose'}" placeholder="{intl l='Mailing template purpose'}" class="form-control">
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
<div class="help-block">{intl l="Enter here the mailing template purpose in the default language ($TITLE)"}</div>
{form_field form=$form field='locale'}
<input type="hidden" name="{$name}" value="{$LOCALE}" />
{/form_field}
<span class="input-group-addon"><img src="{image file="assets/img/flags/{$CODE}.gif"}" alt="{intl l=$TITLE}" /></span>
</div>
{/loop}
</div>
{/form_field}
<div class="help-block">{intl l="Enter here the mailing template purpose in the default language ($TITLE)"}</div>
{/loop}
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="Cancel"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Create this mailing template"}</button>
</div>
</form>
{/form}
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Create this mailing template"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="Cancel"}</button>
</div>
</form>
{/form}
</div>
</div>
{* Delete confirmation dialog *}
<div class="modal hide fade" id="delete_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal fade" id="delete_message_dialog" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a mailing template"}</h3>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3>{intl l="Delete a mailing template"}</h3>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this mailing template ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/messages/delete'}">
<input type="hidden" name="message_id" id="message_delete_id" value="" />
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true"><span class="glyphicon glyphicon-remove"></span> {intl l="No"}</button>
<button type="submit" class="btn btn-default btn-primary"><span class="glyphicon glyphicon-check"></span> {intl l="Yes"}</button>
</div>
</form>
</div>
</div>
<div class="modal-body">
<p>{intl l="Do you really want to delete this mailing template ?"}</p>
</div>
<form method="post" action="{url path='/admin/configuration/messages/delete'}">
<input type="hidden" name="message_id" id="message_delete_id" value="" />
<div class="modal-footer">
<button type="submit" class="btn btn-default btn-primary">{intl l="Yes"}</button>
<button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">{intl l="No"}</button>
</div>
</form>
</div>
{/block}