My form currently has a save button but no apply button. I tried to insert one but it does the same thing as save. Any ideas? Here is the code:
<div class="formelm-buttons">
<button type="button" onclick="Joomla.submitbutton('propform.save')">
<?php echo JText::_('JSAVE') ?>
</button>
<button type="button" onclick="Joomla.submitbutton('propform.cancel')">
<?php echo JText::_('JCANCEL') ?>
</button>
</div>
In short:
Remove
$this->setRedirect($this->getReturnPage());from your save function.Reason it breaks apply:
So this is the function from your comment:
I understand this function is placed inside a controller which extends JControllerForm.
Now, this is pretty badly documented but: JControllerForm::save($key, $urlVar) will set the redirect for you.
This means that when you run
$this->setRedirect($this->getReturnPage());you will override what JControllerForm has already done for you. The difference between save and apply is where to redirect after a successful save.So if you remove that setRedirect, the apply should start working (if everything else is alright). Also if you have constructed the table for this save correctly the $urlVar parameter will be set for you. So if that is the case, you don’t need to override save at all.