php - Save multiple tabular input in Yii -



php - Save multiple tabular input in Yii -

i'm wondering how can insert tabular info in yii.

of course, i've followed docs in aspect there few differences in situation.

first of all, want save 2 models, in docs article. main difference there might more 1 element sec model (simple 1 many relation in database).

i utilize chtml build forms. implemented jquery snippet add together more input groups dynamically.

i'm unable show code it's totally messed , not working currently.

my main question is: how handle array of elements sec model in yii?

define 2 models in controller

$model1= new model1(); $model2= new model2(); //massive assignments $model1->attributes=$_post['model1'] $model2->attributes=$_post['model2'] //validation $valid= $model1->validate(); $valid =$valid && $model2->validate(); if($valid){ $model1->save(false); $model1->save(false); }

if want access fields individually dump post , can view the post array format or instead of doing massive assignments can manually assign this

$model1->field1 =$_post['model1']['field1']; //validation logic ... if($valid){ $model1->save(false); $model1->save(false); }

php yii

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -