// #PSFV-94 : Submit button integrated to the toolbar on add/edit form view

This commit is contained in:
dSevere
2011-11-03 17:58:19 +00:00
parent 40882af794
commit 1f1bebab8e
3 changed files with 41 additions and 6 deletions
@@ -69,7 +69,7 @@
{include file="toolbar.tpl" toolbar_btn=$toolbar_btn} {include file="toolbar.tpl" toolbar_btn=$toolbar_btn}
{/if} {/if}
{if isset($fields.title)}<h2>{$fields.title}</h2>{/if} {if isset($fields.title)}<h2>{$fields.title}</h2>{/if}
<form class="defaultForm" action="{$current}&{$submit_action}=1&token={$token}" method="post" enctype="multipart/form-data"> <form id="{$table}_form" class="defaultForm" action="{$current}&{$submit_action}=1&token={$token}" method="post" enctype="multipart/form-data">
{if $form_id} {if $form_id}
<input type="hidden" name="id_{$table}" id="id_{$table}" value="{$form_id}" /> <input type="hidden" name="id_{$table}" id="id_{$table}" value="{$form_id}" />
{/if} {/if}
@@ -301,6 +301,7 @@
{elseif $key == 'submit'} {elseif $key == 'submit'}
<div class="margin-form"> <div class="margin-form">
<input type="submit" <input type="submit"
id="{$table}_form_submit_btn"
value="{$field.title}" value="{$field.title}"
name="{$submit_action}{if isset($field.stay) && $field.stay}AndStay{/if}" name="{$submit_action}{if isset($field.stay) && $field.stay}AndStay{/if}"
{if isset($field.class)}class="{$field.class}"{/if} /> {if isset($field.class)}class="{$field.class}"{/if} />
@@ -320,6 +321,7 @@
<script type="text/javascript" src="'../js/tinymce.inc.js"></script> <script type="text/javascript" src="'../js/tinymce.inc.js"></script>
{/if} {/if}
</fieldset> </fieldset>
{block name="other_fieldsets"}{/block}
</form> </form>
<br /><br /> <br /><br />
+31 -2
View File
@@ -29,8 +29,9 @@
<ul class="cc_button"> <ul class="cc_button">
{foreach from=$toolbar_btn item=btn key=k} {foreach from=$toolbar_btn item=btn key=k}
<li> <li>
<a class="toolbar_btn" href="{$btn.href}" title="{$btn.desc}"> <a id="desc-{$table}-{$btn.imgclass|default:$k}" class="toolbar_btn" href="{$btn.href}" title="{$btn.desc}">
<span class="process-icon-{$btn.imgclass|default:$k} {$btn.class|default:'' }" ></span>{$btn.desc} <span class="process-icon-{$btn.imgclass|default:$k} {$btn.class|default:'' }" ></span>
<div>{$btn.desc}</div>
</a> </a>
</li> </li>
{/foreach} {/foreach}
@@ -40,5 +41,33 @@
<span id="current_obj" style="font-weight: normal;">{$title|default:'&nbsp;'}</span> <span id="current_obj" style="font-weight: normal;">{$title|default:'&nbsp;'}</span>
{/block}</h3> {/block}</h3>
</div> </div>
<script language="javascript">
$(function() {
//get reference on save link
btn_save = $('span[class~="process-icon-save"]').parent();
//get reference on form submit button
btn_submit = $('#{$table}_form_submit_btn');
//get reference on current save link label
lbl_save = $('#desc-{$table}-save div');
//override save link label with submit button value
lbl_save.html(btn_submit.attr("value"));
//add hidden input to emulate submit button click when posting the form -> field name posted
btn_submit.before('<input type="hidden" name="'+btn_submit.attr("name")+'" value="1" />');
//hide standard submit button
btn_submit.hide();
//submit the form
{block name=formSubmit}
btn_save.click(function() {
$('#{$table}_form').submit();
});
{/block}
});
</script>
{/block} {/block}
</div> </div>
+7 -3
View File
@@ -735,6 +735,11 @@ class AdminControllerCore extends Controller
// @todo defining default buttons // @todo defining default buttons
case 'add': case 'add':
case 'edit': case 'edit':
$this->toolbar_btn['save'] = array(
'href' => '#',
'desc' => $this->l('Save')
);
break;
case 'options': case 'options':
break; break;
default: // list default: // list
@@ -1200,7 +1205,6 @@ class AdminControllerCore extends Controller
$helper->token = $this->token; $helper->token = $this->token;
$helper->specificConfirmDelete = $this->specificConfirmDelete; $helper->specificConfirmDelete = $this->specificConfirmDelete;
$helper->imageType = $this->imageType; $helper->imageType = $this->imageType;
$helper->no_add = isset($this->no_add) ? $this->no_add : false;
$helper->simple_header = isset($this->simple_header) ? $this->simple_header : false; $helper->simple_header = isset($this->simple_header) ? $this->simple_header : false;
$helper->no_link = $this->list_no_link; $helper->no_link = $this->list_no_link;
$helper->colorOnBackground = $this->colorOnBackground; $helper->colorOnBackground = $this->colorOnBackground;
@@ -1240,9 +1244,9 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['view']) if ($this->tabAccess['view'])
{ {
if (Tools::getValue('back')) if (Tools::getValue('back'))
$this->tpl_vars['back'] = Tools::safeOutput(Tools::getValue('back')); $helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue('back'));
else else
$this->tpl_vars['back'] = Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token)); $helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue(self::$currentIndex.'&token='.$this->token));
} }
return $helper->generateForm($this->fields_form); return $helper->generateForm($this->fields_form);
} }