// #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}
{/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}
<input type="hidden" name="id_{$table}" id="id_{$table}" value="{$form_id}" />
{/if}
@@ -301,6 +301,7 @@
{elseif $key == 'submit'}
<div class="margin-form">
<input type="submit"
id="{$table}_form_submit_btn"
value="{$field.title}"
name="{$submit_action}{if isset($field.stay) && $field.stay}AndStay{/if}"
{if isset($field.class)}class="{$field.class}"{/if} />
@@ -320,6 +321,7 @@
<script type="text/javascript" src="'../js/tinymce.inc.js"></script>
{/if}
</fieldset>
{block name="other_fieldsets"}{/block}
</form>
<br /><br />
+31 -2
View File
@@ -29,8 +29,9 @@
<ul class="cc_button">
{foreach from=$toolbar_btn item=btn key=k}
<li>
<a class="toolbar_btn" href="{$btn.href}" title="{$btn.desc}">
<span class="process-icon-{$btn.imgclass|default:$k} {$btn.class|default:'' }" ></span>{$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>
<div>{$btn.desc}</div>
</a>
</li>
{/foreach}
@@ -40,5 +41,33 @@
<span id="current_obj" style="font-weight: normal;">{$title|default:'&nbsp;'}</span>
{/block}</h3>
</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}
</div>
+7 -3
View File
@@ -735,6 +735,11 @@ class AdminControllerCore extends Controller
// @todo defining default buttons
case 'add':
case 'edit':
$this->toolbar_btn['save'] = array(
'href' => '#',
'desc' => $this->l('Save')
);
break;
case 'options':
break;
default: // list
@@ -1200,7 +1205,6 @@ class AdminControllerCore extends Controller
$helper->token = $this->token;
$helper->specificConfirmDelete = $this->specificConfirmDelete;
$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->no_link = $this->list_no_link;
$helper->colorOnBackground = $this->colorOnBackground;
@@ -1240,9 +1244,9 @@ class AdminControllerCore extends Controller
if ($this->tabAccess['view'])
{
if (Tools::getValue('back'))
$this->tpl_vars['back'] = Tools::safeOutput(Tools::getValue('back'));
$helper->tpl_vars['back'] = Tools::safeOutput(Tools::getValue('back'));
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);
}