yii2 cant save form value to db $model->getErrors() says fileds are blank -


guys im trying submit forms values db not save tryed $model->geterror method see error :

array ( [name] => array ( [0] => نام cannot blank. ) [family] => array ( [0] => فامیلی cannot blank. ) [phone] => array ( [0] => شماره تماس cannot blank. ) [email] => array ( [0] => ایمیل cannot blank. ) [address] => array ( [0] => آدرس cannot blank. ) [brithday] => array ( [0] => سال تولد cannot blank. ) [age] => array ( [0] => سن cannot blank. ) [ability] => array ( [0] => توانایی cannot blank. ) [role] => array ( [0] => نقش cannot blank. ) ) 

as see fields empety not empety accourding browser inspect network set! + changing rule filter in model class didnt me + used $model->save(false) create empety row in table without data can please tell me wrong here can see network log :

developers[name]:gholi developers[family]:gholizade developers[phone]:1234567890 developers[email]:aa@aa.com developers[address]:aa ciry developers[brithday]:1396/05/02 developers[age]:123 developers[ability]:php developers[role]:develoer developers[join_date]: 

this controller action create

   public function actioncreate()     {          $model = new developers();          if (yii::$app->request->post()) {             $model->join_date = date('y-m-d h:m:s');             if ($model->save()){                 echo 1;             }else{                 print_r($model->geterrors());             }         } else {             return $this->render('_form', [                 'model' => $model             ]);         }      } 

and form page

<div class="developer-form">          <?php $form = activeform::begin([             'id' => $model->formname(),             'enableajaxvalidation' => true,             'validationurl'=>\yii\helpers\url::toroute('admin/site-admin/validation')         ]); ?>          <?= $form->field($model, 'name')->textinput(['minlength'=>true]) ?>         <?= $form->field($model, 'family')->textinput() ?>         <?= $form->field($model, 'phone')->textinput() ?>         <?= $form->field($model, 'email')->textinput() ?>         <?= $form->field($model, 'address')->textinput() ?>         <?= $form->field($model, 'brithday')->widget(jdate\datepicker::classname()) ?>         <?= $form->field($model, 'age')->textinput() ?>         <?= $form->field($model, 'ability')->textinput() ?>         <?= $form->field($model, 'role')->textinput() ?>         <?= $form->field($model, 'join_date')->textinput() ?>           <div class="form-group">             <?= html::submitbutton($model->isnewrecord ? 'create' : 'update', ['class' => $model->isnewrecord ? 'btn btn-success' : 'btn btn-primary']) ?>         </div>          <?php activeform::end(); ?>     </div> 

and model class

class developers extends activerecord {       public static function tablename()     {         return 'developers';     }       public function rules()     {         return [             [[                 'name',                 'family',                 'phone',                 'email',                 'address',                 'brithday',                 'age',                 'ability',                 'role',             ], 'required'],             [['join_date'], 'safe'],             ['email', 'email'],             [['phone'], 'integer', 'min' => 10],             [['address'], 'string', 'max' => 100],             [['name'], 'string', 'min' => 3],           ];     } 

youre not loading values model, change if to:

if($model->load(yii::$app->request->post())) { 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -