How to 'unlock' a field in a CakePHP form when it is part of a hasMany association

后端 未结 2 1753
难免孤独
难免孤独 2021-01-21 21:40

I have a form that represents a RewardModifier table in our database. That RewardModifier hasMany RewardOption.

My fo

相关标签:
2条回答
  • 2021-01-21 21:53

    I had a similar problem. I found adding (the equivalent of) this to the RewardModifier controller did the trick:

    public function beforeFilter(){
         $this->Security->unlockedFields = array('RewardOption');
    }
    
    0 讨论(0)
  • 2021-01-21 22:13

    Adding the following to the form code worked for me

    $this->Form->unlockField('User.id');
    

    Unlocking the fields from within the view files also helps declutter the controller's beforeFilter().

    Source: /core-libraries/helpers/form.html#FormHelper::unlockField

    0 讨论(0)
提交回复
热议问题