I want to create form using CFormModel and CActiveRecord, is that possible? Form view is working fine but submit action is not working bcz one text field which I create using CFormModel and other two fields using CActiveRecord. Any idea?
I want to create form using CFormModel and CActiveRecord, is that possible? Form view is working fine but submit action is not working bcz one text field which I create using CFormModel and other two fields using CActiveRecord. Any idea?
You should use either AR or CFormModel. If you need additional fields in your active record, just add them manually. They’ll not get stored in your db and act like attributues of a form model.
Could you show me an example?
I’ve just added two fields to my User model like that:
class User extends CActiveRecord
{
/**
* The followings are the available columns in table 'User':
* @var integer $uid
* @var string $password
* @var string $username
* @var string $email
* @var string $profile
*/
public $password2;
public $verifyCode;
...
}
but it doesn’t work correctly. I’m trying to send data through form, and I see in $_POST[‘User’] all the values, but validator says, that password2 and verifyCode are empty (according to my rules).
Have I done smth amiss?
PS: this is my second day in Yii, and Yii is my first framework, so excuse my naivety.
Add this (Yii 1.0.x)
public function safeAttributes() {
return array(
'password2, verifyCode, ..., ...',
);
}
/Tommy
how to make a form that saved to multiple tables? thx
Thanks awfully!