i have this model
<?php
class Profile extends CActiveRecord
{
/**
* The followings are the available columns in table 'Profile':
* @var integer $userId
* @var string $firstName
* @var string $lastName
* @var string $middleName
* @var integer $gender
* @var string $birthDate
*/
/**
* Returns the static model of the specified AR class.
* @return CActiveRecord the static model class
*/
public static function model($className=__CLASS__)
{
return parent::model($className);
}
/**
* @return string the associated database table name
*/
public function tableName()
{
return 'profile';
}
/**
* @return array validation rules for model attributes.
*/
public function rules()
{
// NOTE: you should only define rules for those attributes that
// will receive user inputs.
return array(
array('userId, firstName, lastName, gender, birthDate', 'required'),
array('userId, gender', 'numerical', 'integerOnly'=>true),
array('firstName, lastName', 'length', 'max'=>50),
array('middleName', 'length', 'max'=>100),
);
}
/**
* @return array relational rules.
*/
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'user' => array(self::BELONGS_TO, 'User', 'userId'),
);
}
/**
* @return array customized attribute labels (name=>label)
*/
public function attributeLabels()
{
return array(
'userId' => 'User',
'firstName' => 'First Name',
'lastName' => 'Last Name',
'middleName' => 'Middle Name',
'gender' => 'Gender',
'birthDate' => 'Birth Date',
);
}
}
i tried to use yiic shell crud command on it, however this form that is generated is missing a field.
<div class="yiiForm">
<p>
Fields with <span class="required">*</span> are required.
</p>
<?php echo CHtml::beginForm(); ?>
<?php echo CHtml::errorSummary($model); ?>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'firstName'); ?>
<?php echo CHtml::activeTextField($model,'firstName',array('size'=>50,'maxlength'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'lastName'); ?>
<?php echo CHtml::activeTextField($model,'lastName',array('size'=>50,'maxlength'=>50)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'middleName'); ?>
<?php echo CHtml::activeTextField($model,'middleName',array('size'=>60,'maxlength'=>100)); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'gender'); ?>
<?php echo CHtml::activeTextField($model,'gender'); ?>
</div>
<div class="simple">
<?php echo CHtml::activeLabelEx($model,'birthDate'); ?>
<?php echo CHtml::activeTextField($model,'birthDate'); ?>
</div>
<div class="action">
<?php echo CHtml::submitButton($update ? 'Save' : 'Create'); ?>
</div>
<?php echo CHtml::endForm(); ?>
</div><!-- yiiForm -->
I don’t think that is supposed to be right. For my other models, forms are generated with all the fields.