php - Why do i get the null value in database? -


public function actionevent()  {     $event= new events();     $address=new addresses();     if($event->load(yii::$app->request->post()) && $event->save() && $address->load(yii::$app->request->post()) && $address->save())     {          echo $event->name;         return $this->render('sucess',['event'=>$event]);      }     else{         return $this->render('event',[             'event'=>$event,         'address'=>$address,         ]);     } } 

i don't record have posted in view form ,i null in database.why?

i think should indicate name of form element want load inside model

given yii2 load documentation

public boolean load ( $data, $formname = null )

the form name use load data model. if not set, formname() used.

and in case form-name don't match model

try way

if($event->load(yii::$app->request->post('event')) && $event->save() && $address->load(yii::$app->request->post('eddress')) && $address->save()) 

or should value

 load($_post['event'])    load($_post['address'])   

and assign propose.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -