我在allergy
表格中添加了字段user
。但在提交表单后,它不会被插入。我是Yii的新手。我没有使用任何Gii生成器,因为这是现有的代码库。是否可以在此处尝试添加新字段,或者我应该运行任何Yii生成器(模型,CRUD)
我改变了以下几个方面。
\保护\视图\ userManagement \ user.php的
<?php echo $form->labelEx($model,'allergy'); ?>
<?php echo $form->error($model,'allergy'); ?>
\保护\模型\ user.php的
In the attributeLabels() function:
'allergy' => 'Allergy',
In the search() function:
$criteria->compare('allergy',$this->allergy);
In the beforeSave() function:
if($this->allergy=='')
$this->setAttribute('allergy', NULL);
else
$this->setAttribute('allergy', $this->allergy);