Frontend save &new button

For Joomla! 3.x Coding related discussions, please use: http://groups.google.com/group/joomla-dev-general

Moderator: ooffick

Forum rules
Please use the mailing list here: http://groups.google.com/group/joomla-dev-general rather than this forum.
Post Reply
bonnie_lass
Joomla! Apprentice
Joomla! Apprentice
Posts: 9
Joined: Mon Aug 11, 2008 2:17 pm

Frontend save &new button

Post by bonnie_lass » Wed May 27, 2020 5:27 pm

I have a custom component form that I want to add a button to submit save and return to add form again.
Right now it's just save and cancel and I'm trying to figure out how to add a third button "Save & new" for faster entry.
The save button triggers a control function and I thought maybe I could add a second function called save2new and have the new button trigger that function.

The original submit button:

Code: Select all

<button type="submit" class="validate btn btn-primary"><?php echo Text::_('JSUBMIT'); ?></button>
I tried changing the buttons to:

Code: Select all

<button onclick="Joomla.submitbutton('index.php?option=com_mycomp&task=mycompform.save');" class="validate btn btn-primary"><?php echo Text::_('JSUBMIT'); ?></button>
                      
<button onclick="Joomla.submitbutton('index.php?option=com_mycomp&task=mycompform.save2new');" class="validate btn btn-primary">Save & new</button>
but I see a hidden field in the original form with the save task set in a hidden field

Code: Select all

<input type="hidden" name="task" value="mycompform.save"/>
and also the save task in form action

Code: Select all

<form id="form-mycomp" action="<?php echo Route::_('index.php?option=com_mycomp&task=mycompform.save'); ?>"
Does this mean the save function is still being called no matter what my button says?

Am I thinking all wrong in trying to create a second save and new function? And if not, how do I make the form handle both buttons? I can't get it working so I must be missing something or a control function isn't the right way? Been googling all day for a front end save & new button solution but haven't really found anything. Any ideas would be appreciated!

 
 
Post Reply

Return to “Joomla! 3.x Coding”