I have in my CustomerExtended - is a Customer Active Record extended - a public attribute called $notifications, witch setted in afterConstruct method:
class CustomerExtended extends Customer
{
public $notifications;
public function afterConstruct()
{
parent::afterConstruct();
$this->notifications = Array(
'customer_notify_new_sms',
'customer_notify_new_pokes',
'customer_notify_news_by_email',
'customer_notify_favorite_logged',
'customer_notify_finantial_response'
);
}
}
And Customer has the following attributes - are concrete attributes from database:
$customer = new Customer();
$customer->customer_notify_new_sms; // default is 1 on database
$customer->customer_notify_new_pokes; // default is 1 on database
$customer->customer_notify_news_by_email; // default is 1 on database
$customer->customer_notify_favorite_logged; // default is 1 on database
$customer->customer_notify_finantial_response; // default is 0 on database
Right, I need that the notification attribute on CustomerExtended be a array representing the concrete attributes - with correspondent names - on Customer Active Record. This is to create a checkboxlist.
I’m trying to found a solution but… I’m trying thus:
$model = new CustomerExtended();
$form = new CActiveForm();
echo $form->checkBoxList($model, 'notifications',
Array(
'customer_notify_new_sms' => 'News by SMS',
'customer_notify_new_pokes' => 'Notify Pokes',
'customer_notify_news_by_email' => 'Notify by e-mail',
'customer_notify_favorite_logged' => 'Notify when favorite is logged',
'customer_notify_finantial_response' => 'Notify finantial reports'
)
);
But the result is wrong, 'cause customer_notify_finantial_response attribute is 0 on database and on the checkboxlist is checked by default.
Is there a better way to do this?
I’m new here and I not can post external images to exemplify:(