This was driving me nuts for the better part of the day.
Thinking I was screwing up somewhere, I kept reviewing and reviewing till I finally set
"prod_cats": {
"0": {
"prod_categories": "4fac1990c1ccc21d29000000",
"": null
}
Here’s part of my form, the [0] is intended as a placeholder till I add a loop to it.
<div class="row">
<script type="text/javascript">
$(document).ready(function() {
$('#ProdCategories_0_prod_categories').val('<?php echo $model->prod_cats['0']['prod_categories']; ?>');
});</script>
<?php
$model->prod_cats[0] = new ProdCategories();
?>
<div class="two columns"><?php echo $form->labelEx($model->prod_cats[0],'prod_categories'); ?></div>
<div class="eight columns"><?php echo $form->dropDownList($model->prod_cats[0],"[0]prod_categories", $catList); ?>
<?php echo $form->error($model->prod_cats[0],'prod_categories'); ?></div>
</div>
Then my Controller
$model->prod_cats[0]= new ProdCategories;
$model->prod_cats[0]->prod_categories = $_POST['ProdCategories']['0']['prod_categories'];
I already have arrays of more complex embedded documents, this one is causing the most headaches