Difference between #3 and #4 of
How to use a single form to collect data for two or more models?

Revision #4 has been created by qiang on Mar 11, 2009, 8:15:41 PM with the memo:

Reverted back to #1. Mentioning _form.php distracts the attention to the problem.
« previous (#3) next (#5) »

Changes

Title unchanged

How to use a single form to collect data for two or more models?

Category unchanged

Tutorials

Yii version unchanged

Tags unchanged

Content changed

[...]
...input fields for $a, $b...

</form>
```

The above approach can also be used if we have more than two models to deal with.

 
 
 
 
Now, since version 1.0.3 and the `_form.php` view things change a litle. Folowing the example, we need to redlclare en the `create` view the parameters passed to the `create` view so the `_form` view can use them.
 
 
```php 
<h2>Create view</h2>
 
 
<div class="actionBar">
 
[<?php echo CHtml::link('List',array('list')); ?>]
 
[<?php echo CHtml::link('Manage',array('admin')); ?>]
 
</div>
 
 
<?php echo $this->renderPartial('_form', array(
 
'a'=>$a,'b'=>$b,
 
'update'=>false,
 
)); ?>
 
```
 
 
And in the `_form` work as ever (i.e. we can use $a and $b)
 
 
88 0
79 followers
Viewed: 353 741 times
Version: 1.1
Category: Tutorials
Written by: qiang
Last updated by: Yang He
Created on: Feb 27, 2009
Last updated: 12 years ago
Update Article

Revisions

View all history