Yii form question

yii documentation says:

foreach($_POST['LoginForm'] as $name=>$value)
{
    if($name is a safe attribute)
        $model->$name=$value;
}

What is the LoginForm array taken from? which attribute is associated with?

+3
source share
2 answers

In PHP, $ _POST contains input fields placed 'from an HTML form.

In an HTML form, elements have names

Address: <input type='text' name='LoginForm[addr]'>
City: <input type='text' name='LoginForm[city]'>
ST: <input type='text' name='LoginForm[st]'>

So, when PHP provides this input to the script, it injects names into the array by names that you can use the iterator with foreach.

+3
source

Array of $ _POST? if it is a reserved / predefined variable, and this content is usually the result of the resulting forms. Is this what you are asking for?

http://www.php.net/manual/en/reserved.variables.php

0
source

Source: https://habr.com/ru/post/1731321/


All Articles