If I have a form with a few buttons in it, is there a way I can change the action which is run on the controller when the button is clicked without using javascript?
I am trying to create a toolbar.
If I have a form with a few buttons in it, is there a way I can change the action which is run on the controller when the button is clicked without using javascript?
I am trying to create a toolbar.
In same form, I'm using this way:
<?php echo CHtml::form('index.php?r=eventos/addEvent1'); ?>
input name
…
</form>
<?php echo CHtml::form('index.php?r=eventos/addEvent2'); ?>
input date
…
</form>
"eventos" is my EventosController.php and inside it I add the actions:
// get form1
public function actionAddEvent1()
{
// just a test
echo $_POST['name'];
}
get form2
public function actionAddEvent2()
{
// just a test
echo $_POST['date'];
}
I hope this helps you
Just call a wrapper action and then select the action
public function actionWrapper(){ if($_POST['data']==1){ $this->actionselection1(); }else{ $this->actionselection2(); } }
I'd recommend you to have ONE action for the whole toolbar and multiple submethods to handle each button's clicks. Remember: one form = one action.