CakePHP 2.0 Determine which submit button has been clicked

后端 未结 4 1801
暖寄归人
暖寄归人 2021-02-06 00:20

In CakePHP 1.3 you can create a form with multiple submit buttons:

echo $this->Form->submit(\'Submit 1\', array(\'name\'=>\'submit\');
echo $this->Fo         


        
4条回答
  •  不要未来只要你来
    2021-02-06 00:57

    in 2.0 there is no $this->params['form'] anymore all form helper posted fields end up in $this->data (which makes more sense anyway)

    so

    if (!empty($this->data['submit']) && $this->data['submit'] == "Submit 1") {}
    

    note that !empty() is better here as well.

    PS: you can use my enhanced upgrade shell to replace it in your code: https://github.com/dereuromark/upgrade

    its the command

    cake Upgrade.Upgrade request
    

    (https://github.com/dereuromark/upgrade/blob/master/Console/Command/UpgradeShell.php#L833)

提交回复
热议问题