On Nov 7, 12:52 pm, I, ("R. Rajesh Jeba Anbiah" <[EMAIL PROTECTED]>) wrote: > Previous discussions: > 1. http://groups.google.com/group/cake-php/browse_thread/thread/856cda8e... > 2.https://trac.cakephp.org/ticket/2473 > > Summary: > I still don't get it working. > > Case: > 1. add.ctp > $form->create('model1') > ... > $form->input('a'); > $form->input('b'); > $form->input('model2.x'); > > 2. controller1::add() > $this->model1->save($this->data); > $this->model1->model2->save($this->data['model2']);
After digging little deeper, I seem to get the following working. But, it may not be bulletproof solution. > Problem: > 1. $form->input('model2.x'); doesn't render input field with required > class. Note, model2->validate['x'] is set with proper rules. The problem is that at FormHelper::input() #558, $this->model() correctly resolves, but $this->fieldset doesn't resolve right (it contains fields of model1 only). I had patch: if (in_array($this->field(), $this->fieldset['validates'])) { with $modelObject =& ClassRegistry::getObject($this->model()); if (isset($modelObject->validate[$this->field()])) { And it seems to be working. > 2. From controller1::add() > $this->model1->model2->save($this->data['model2']) correctly shows the > validation error message in 'model2.x' > 3. *But*, from controller1::add() > $this->model1->model2->validates() doesn't show validation error > message in 'model2.x'--it always get validated. This seems to be my misunderstanding of validates(). I had to call it like: $this->model1->model2->data = $this->data['model2']; $this->model1->model2->validates(); If there is any other official way, kindly share. -- <?php echo 'Just another PHP saint'; ?> Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---