所以我有一个这样的模型:
class MyClass
{
public $customer = null;
public $address = null;
}
像这样的形式:
class MyForm extends CFormModel
{
public $customer = null;
public $address = null;
/**
* Declares the validation rules.
*/
public function rules()
{
return array(
array('customer, address', 'required'),
array('verifyCode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
);
/**
* Declares customized attribute labels.
* If not declared here, an attribute would have a label that is
* the same as its name with the first letter in upper case.
*/
public function attributeLabels()
{
return array(
'verifyCode'=>'Verification Code',
);
}
}
我想做的是在我的表单中扩展模型,但是你不能在 PHP 中进行多对象继承。
我将如何做到这一点,以避免在表单中复制模型的所有字段属性?