[SOLVED] controller action 400 error with multiple models

Hi, I was wondering if someone could help explain why a controller update method returns a 400 error when there are two (different) models on the page?

I’m talking in particular about an update action I have which requires an $id param (it’s a default gii created CRUD update method), ie;


/**

 * Updates a particular model.

 * If update is successful, the browser will be redirected to the 'index' page.

 *

 * @param integer $id the ID of the model to be updated

 */

public function actionUpdate($id)

{

The form was working originally, however in my application ‘modelA’ contains many 'modelB’s, so I’m allowing the user to add 'modelB’s to a ‘modelA’ on the ‘update’ screen for ‘modelA’.

When I add the code for adding a ‘modelB’ to the update page I’m getting a 400 Invalid Request error when I submit the form. I think I’ve narrowed this down to the system not picking up the $id parameter;

On my update view page, the models are named differently, and the form starts;


$form=$this->beginWidget('CActiveForm', array(

    'id'=>'modelA-form',

    'action'=>$model->isNewRecord ? array('modelA/create') :  '',

    'enableAjaxValidation'=>false,

    'htmlOptions' => array('enctype' => 'multipart/form-data'),

)); ?>

The output <form> tag is still correct;


<form enctype="multipart/form-data" id="modelA-form" action="/modelA/update/301" method="post">

It works absolutely fine when I take modelB out of the form, is there an obvious solution to this I’m missing?

thanks,

Stu

Ignore that, it was a redirect I was using was redirecting to modelA/update without the id on the end of the URL causing the error… whoops!