E
E
EVOSandru62014-12-23 04:01:53
Yii
EVOSandru6, 2014-12-23 04:01:53

Based on what is the name of the $_POST array element formed in Yii when sending data from _form?

For example:

if(isset($_POST['Product']))
    {
      $model->attributes=$_POST['Product'];
      if($model->save())
        $this->redirect(array('view','id'=>$model->CODE));
    }

Here, of course, you can guess that this is because of the name of the model, but is it possible to change the name of the element in some way? I would like to make an inherited controller and make an identical form for 2 models with the same name.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
index0h, 2014-12-23
@index0h

It is possible to prescribe name for fields in htmlOptions. It is much cheaper and safer to specify a variable with the name of the working model class in the controller.
Z.Y. Better use HttpRequest instead of $_POST

A
Andrey Uldin, 2015-01-26
@Slash

In fact, when you generate a form in a view, for example, through TbActiveForm, you pass the model there. The fields are formed from the name of this model.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question