Gii model generation not getting past first step - strange problem

I’ve installed the latest version of yii2 using the advanced template. The website is working fine. For some reason the Gii generation tool is stuck and does not react as expected after clicking the preview button. Instead of showing a new form with the “Generate” button, it shows the same form unchanged without any messages as to what is happening.

Using xdebug I can see in the “actionView” method of the DefaultController that the array value $_POST[‘preview’] is not set, i.e. it doesn’t exist in the $_POST array. I have not changed anything in the Form of the view and everything looks OK. The submit button has the name “preview” and the form is submitted but the $_POST array is not being filled with the value of the submit button. Therefore the controller does not proceed with the next steps of the generation process.


    public function actionView($id)

    {

        $generator = $this->loadGenerator($id);

        $params = ['generator' => $generator, 'id' => $id];


        // ###############################################################################

        // ### THIS IF STATEMENT IS NOT TRUE BECAUSE  $_POST['preview'] IS NOT SET !!! ###

        // ###############################################################################

        if (isset($_POST['preview']) || isset($_POST['generate'])) {

        // ###############################################################################


            if ($generator->validate()) {

                $generator->saveStickyAttributes();

                $files = $generator->generate();

                if (isset($_POST['generate']) && !empty($_POST['answers'])) {

                    $params['hasError'] = !$generator->save($files, (array) $_POST['answers'], $results);

                    $params['results'] = $results;

                } else {

                    $params['files'] = $files;

                    $params['answers'] = isset($_POST['answers']) ? $_POST['answers'] : null;

                }

            }

        }


        return $this->render('view', $params);

    }

Does anyone have an idea what could be causing this?

I’ve found the problem. The GII view, view.php, is generating the form incorrectly and causing the value of the button to not be included in the resulting Post. The reason is that the value option of the submit button is missing.

I hope to issue a bug fix and pull request shortly.

I’ve submitted pull request #6824