0

I'm using Cakephp v 2.5.1 with the Security component. I have a profile form where I have a HABTM relationship between a user and projects where the user can select 0-N projects (basically a multiselect).

When posting, the post gets blackholed.

Here are the fields from the FormHelper (i.e. $hashParts):

Array ( [0] => /users/profile [1] => a:8:{i:0;s:15:"Project.Project";i:1;s:10:"User.alias";i:2;s:16:"User.division_id";i:3;s:17:"User.geography_id";i:4;s:13:"User.lastname";i:5;s:13:"User.level_id";s:7:"User.id";s:2:"38";s:13:"User.username";s:26:"bobking256@prophecyinc.com";} [2] => currentpassword|newpassword|newpassword2 [3] => Ge08djl2390IOJjl298dj4MNbhzapo8912eadsSTBVD )

Here are the fields from the Security Component ($hashParts) after posting: Array ( [0] => /users/profile [1] => a:9:{i:0;s:15:"Project.Project";i:1;s:10:"User.alias";i:2;s:16:"User.division_id";i:3;s:17:"User.geography_id";i:4;s:13:"User.lastname";i:5;s:13:"User.level_id";i:6;s:11:"multiselect";s:7:"User.id";s:2:"38";s:13:"User.username";s:26:"bobking256@prophecyinc.com";} [2] => currentpassword|newpassword|newpassword2 [3] => Ge08djl2390IOJjl298dj4MNbhzapo8912eadsSTBVD )

Looking at array element [1], there appears to be an extra attribute in the post (the " i:6;s:11;multiselect";)

I have tried to remove this from validation using:

$this->Form->unlockField('Project.Project')

but it doesn't work. It removes the 'Project.Project' from both array element [1] from above but is does not remove the "multiselect" (it becomes i:5;s:11;multiselect)

How can I fix this or at least remove this from the validation?

Thanks.

bk256
  • 1

1 Answers1

0

I received some great help from the cakephp IRC. Since I am using twitter bootstrap, I was including the 'class'=>'multiselect' in my $this->Form->input(...); the solution to fix this was to unlock this field with $this->Form->unlockField('multiselect'); and my post validation issue went away.

Hopefully this may help others in the future.

RavatSinh Sisodiya
  • 1,596
  • 1
  • 20
  • 42
bk256
  • 1