I am using the Security
component in my AppController. I need to build a check form input that will allow custom formatting of each item in the list. To accomplish this, I am processing each item in the $options
set using a foreach and creating the new element like so:
foreach ($fileTypes as $fileType_key => $fileType_value) {
echo $this->Form->input(
'FilesIncluded.' . $fileType_key,
array(
'type' => 'checkbox',
'value' => $fileType_key,
'label' => false,
'div' => false,
'before' => '<span class="checkbox clearfix"><span class="check">',
'after' => '</span><label for="add-product-check-sub-cat">' . $fileType_value . '</label></span>',
'hiddenField' => false,
)
);
}
There is a few things to note:
- I am setting each check box to
data[FilesIncluded][{UUID}]
(where UUID actually represents the UUID pf the FilesIncluded) instead ofdata[FilesIncluded][]
- FilesIncluded is not part of the form model, so it will appear in
$this->request->data
as$this->request->data['FilesIncluded']
instead of$this->request->data['Model']['column']
What I am trying to figure out is why this throws an auth security risk? When I change the field name from 'FilesIncluded.' . $fileType_key
to something with a counter in it like 'FilesIncluded.' . $count . '.id'
, it seems to work without throwing any security auth errors. Any ideas how to make this work the way I am expecting it to?
UPDATE:
The other issue is being able to maintain a fixed set of FileTypes. For example, I want to be able to control the HABTM records that can be selected from the checkbox. For example, I will display this list: http://cl.ly/image/0b1Q3C0d0w1Y
And only when the user selects the records will they be stored as hasMany. Then when it comes time to edit, I want to not only be able to show the same set of records, but then have them associated to the records the user saved.