Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change field name in inspect get internal server error #15535

Closed
mhdizade opened this issue Jan 22, 2018 · 1 comment
Closed

Change field name in inspect get internal server error #15535

mhdizade opened this issue Jan 22, 2018 · 1 comment

Comments

@mhdizade
Copy link

mhdizade commented Jan 22, 2018

What steps will reproduce the problem?

open inspectElement and change field name like this:
from LoginForm[username] change to LoginForm[username][test]
fill form and submit

What is the expected result?

form validation error like invalid username or something not internal server error

What do you get instead?

Error (#8) An internal server error occurred.

Additional info

Q A
Yii version 2.0.5
PHP version 7.0.1
Operating system windows10, centos

when you change the html form input name in inspect, get error#8
open inspect and i select form input like this
<input type="text" id="loginform-username" class="form-control" name="LoginForm[username]" >
and change name of input to this
<input type="text" id="loginform-username" class="form-control" name="LoginForm[username][test]">

and fill the form and press submit and i get this error

PHP Notice – yii\base\ErrorException
Array to string conversion
 in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\helpers\BaseHtml.php at line 537
528529530531532533534535536537538539540541542543544545546     * See [[renderTagAttributes()]] for details on how attributes are being rendered.
     * @return string the generated input tag
     */
    public static function input($type, $name = null, $value = null, $options = [])
    {
        if (!isset($options['type'])) {
            $options['type'] = $type;
        }
        $options['name'] = $name;
        $options['value'] = $value === null ? null : (string) $value;
        return static::tag('input', '', $options);
    }
 
    /**
     * Generates an input button.
     * @param string $label the value attribute. If it is null, the value attribute will not be generated.
     * @param array $options the tag options in terms of name-value pairs. These will be rendered as
     * the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]].
     * If a value is null, the corresponding attribute will not be rendered.
2. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\helpers\BaseHtml.php at line 537 – yii\base\ErrorHandler::handleError(8, 'Array to string conversion', 'C:\xampp\htdocs\yii\ven...', 537, ...)
3. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\helpers\BaseHtml.php at line 1250 – yii\helpers\BaseHtml::input('text', 'LoginForm[username]', ['test' => 'support_admins'], ['class' => 'form-control', 'autofocus' => true, 'id' => 'loginform-username', 'type' => 'text', ...])
4. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\helpers\BaseHtml.php at line 1295 – yii\helpers\BaseHtml::activeInput('text', app\models\LoginForm, 'username', ['class' => 'form-control', 'autofocus' => true, 'id' => 'loginform-username'])
5. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\widgets\ActiveField.php at line 386 – yii\helpers\BaseHtml::activeTextInput(app\models\LoginForm, 'username', ['class' => 'form-control', 'autofocus' => true])
6. in C:\xampp\htdocs\yii\views\site\login.php at line 26 – yii\widgets\ActiveField::textInput(['class' => 'form-control', 'autofocus' => true])
20212223242526272829303132            <p>Please fill out the following fields to login:</p>
 
            <?php $form = ActiveForm::begin([
                'id' => 'login-form',
            ]); ?>
 
            <?= $form->field($model, 'username')->textInput(['autofocus' => true]) ?>
 
            <?= $form->field($model, 'password')->passwordInput() ?>
 
            <?= $form->field($model, 'rememberMe')->checkbox() ?>
 
            <div class="form-group">
7. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\View.php at line 326 – require('C:\xampp\htdocs\yii\vie...')
8. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\View.php at line 248 – yii\base\View::renderPhpFile('C:\xampp\htdocs\yii\vie...', ['model' => app\models\LoginForm])
9. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\View.php at line 150 – yii\base\View::renderFile('C:\xampp\htdocs\yii\vie...', ['model' => app\models\LoginForm], app\controllers\SiteController)
10. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\Controller.php at line 378 – yii\base\View::render('login', ['model' => app\models\LoginForm], app\controllers\SiteController)
11. in C:\xampp\htdocs\yii\controllers\SiteController.php at line 71 – yii\base\Controller::render('login', ['model' => app\models\LoginForm])
65666768697071727374757677 
        $model = new LoginForm();
        if ($model->load(Yii::$app->request->post()) && $model->login()) {
            return $this->goBack();
        }
        return $this->render('login', [
            'model' => $model,
        ]);
    }
 
    /**
     * Logout action.
     *
12. app\controllers\SiteController::actionLogin()
13. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\InlineAction.php at line 55 – call_user_func_array([app\controllers\SiteController, 'actionLogin'], [])
14. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\Controller.php at line 154 – yii\base\InlineAction::runWithParams([])
15. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\Module.php at line 454 – yii\base\Controller::runAction('login', [])
16. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\web\Application.php at line 100 – yii\base\Module::runAction('site/login', [])
17. in C:\xampp\htdocs\yii\vendor\yiisoft\yii2\base\Application.php at line 375 – yii\web\Application::handleRequest(yii\web\Request)
18. in C:\xampp\htdocs\yii\web\index.php at line 12 – yii\base\Application::run()
6789101112 
require(__DIR__ . '/../vendor/autoload.php');
require(__DIR__ . '/../vendor/yiisoft/yii2/Yii.php');
 
$config = require(__DIR__ . '/../config/web.php');
 
(new yii\web\Application($config))->run();
@mhdizade mhdizade changed the title Change field name get Change field name in inspect get internal server error Jan 22, 2018
@mhdizade mhdizade changed the title Change field name in inspect get internal server error Change field name in inspect get internal server error Jan 22, 2018
@rob006
Copy link
Contributor

rob006 commented Jan 22, 2018

Duplicates #15401

@rob006 rob006 closed this as completed Jan 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants