I'm trying to save on my "Requestc" controller an array with data from a Multiselect chosen script.
My view:
<select data-placeholder="Selecione as certidões" name="certidoes[Requestc][][caminho]" multiple="multiple" style="width:400px;" class="chzn-select">
<?php foreach ($certidao as $certidoes): ?>
<option value="<?php echo $certidoes['Certificate']['id']; ?>"><?php echo $certidoes['Certificate']['nome']; ?></option>
<?php endforeach ?>
</select>
My controller:
if(!empty($solicitacao)) {
$this->request->data['Requestc']['request_id'] = $this->Request->id;
$data = $this->request->data['certidoes'];
$this->Request->Requestc->saveAll($data['Requestc']);
}
And when I save my "request_id", it's still blank.
I think that you need to use a different syntax to modify the data. Check the cookbook
// Modify some request data, so you can prepopulate some form fields.
$this->request->data('Post.title', 'New post')
->data('Comment.1.author', 'Mark');
Not a answer, but to illustrate how this input can be created with the FormHelper;
// Aparently, this variable is not formatted correctly to be used
// directly for options. If possible, use Model::find('list')
// to get it in the right format
$options = array();
foreach ($certidao as $row) {
$options[$row['Certificate']['id']] = $row['Certificate']['nome'];
}
echo $this->Form->input('Requestc.caminho', array(
'type' => 'select',
'multiple' => 'multiple',
'data-placeholder' => 'Something here',
'style' => 'width:400px',
'class' => 'chzn-select',
'options' => $options,
);
Not behind my computer to test, but think it should be fine