In cakephp 3 I got error Unexpected field in POST data. Actually that field is not in my table, but I want to use in controller.
In cakephp 3 I got error Unexpected field in POST data
6.4k views Asked by Masud At
2
There are 2 answers
1

The Security Component in CakePHP is not forgiving. If you want to allow a field thru that should not go thru the Security Component hashing process, you need to use the unlockedField
method that comes with the FormHelper
class as such:
$this->Form->unlockField('field');
If this does not work, you will need to provide us with the pertinent code
I was getting the similar error in cakephp 3.4 I was using the simple html form and input fields. I was passing the input fields data in array. like below:-
Then i do some R&D and found that we need to use the cakephp form helper to create the form and its fields like below :-
In case of pass form data in array
In case of simple input fields you can do the code like below
This work form me and resolve the error Unexpected field in POST data in cakephp 3.4