Model Attributes And Post Problem

In my form




<div class="row">

		<?php echo $form->labelEx($model,'aktif'); ?>

		<?php echo $form->dropDownList($model, 'aktif', array(''=>'Seçiniz',0=>'Pasif', 1=>'Aktif'));?>

		<?php echo $form->error($model,'aktif'); ?>

	</div>




I am posting KurumsalSite Form but an attribute “aktif” which belongs to Kurumsalsite i can’t assign to $model->attributes . When i assign to




if(isset($_POST['KurumsalSite']))

{

$model->attributes=$_POST['KurumsalSite'];

}



"$model->aktif" is always "1". But, when i use this assignment


$model->aktif = $_POST['KurumsalSite']['aktif']

it is working. In my database (database is mysql) aktif field is tinyint. I don’t want to write extra code. What is the problem . ::)

if "aktif" is model attribute again why you are assigning?

For recording different ‘aktif’ variables(0 or 1) to mysql.

Aktif is not static data it is dynamica data which is 0 or 1 . If user selects aktif 0 from form it comes 0 but if i want to assign model->attributes to POST attributes, it is always 1. I don’t understand this situation.

check model rules

My model.




return array(

array('genislik, yukseklik, metin, aktif', 'required'),

array('id, site_id, genislik, yukseklik, aktif', 'numerical', 'integerOnly'=>true),

// The following rule is used by search().

// Please remove those attributes that should not be searched.

array('id, site_id, genislik, yukseklik, metin, aktif', 'safe', 'on'=>'search'),

);



Is it wrong ?

Will you explain your problem a bit more comprehensively.As far as I can gather,You have an attribute named ‘atkif’ which is a tinyint and you need to save it in your model.

FIrst of all Use a checkbox which will be better than a dropdownlist.Secondly,if it is a model attribute then $model->attribute=$_POST[‘FormName’] should work.If not set separately, using $model->atkif=$_POST[‘FormName’][‘field name’].

Thank you for your kindly message, but i think i explained my problem compherensively in my previous posts . You say


$model->attribute=$_POST['FormName']

should work, but it is not working exactly for this situation. I have also solve my problem with


$model->atkif=$_POST['FormName']['field name']

but why


$model->attribute=$_POST['FormName']

isn’t work i didn’t understand.

Hi drxy,

Well, I see nothing wrong so far in your posted code.

Would you please post your code of the controller action as a whole?