Changes
Title
changed
Update two models with one view
Category
unchanged
Tips
Yii version
unchanged
Tags
changed
database, model, view, form
Content
changed
Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).
```php
<?php $form = $this->beginWidget(‘CActiveForm’, array(
‘id’ => ‘
anagraficheusers-form’,
‘enableAjaxValidation’ => false )); ?>
<?php echo $form->labelEx($model, ‘username’); ?>[...]
```php
<?php $form = $this->beginWidget(‘CActiveForm’, array(
‘id’ => ‘anagraficheusers-form’,
‘enableAjaxValidation’ => false )); ?>
<?php echo $form->labelEx($model, ‘username’); ?>
<?php echo $form->textField($model, ‘username’, array(‘size’ => 60, ‘maxlength’ => 250)); ?>
<?php echo $form->error($model, ‘username’); ?>
<?php echo $form->labelEx(Emails::model(), ‘email’); ?>[...]