0

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 have a hunch that it is something quite simple that I'm overlooking, but I've never had a situation where POST variable from a Form are not being sent to the server.

andypotter
  • 130
  • 6
  • BTW - it is not the CASE that the Framework, Router, Controller etc, is removing the value from the Array. The value is missing from the very beginning. – andypotter Jan 10 '15 at 12:30

1 Answers1

0

False Alarm. I've found the problem. The Gii view was creating the HTML Form incorrectly.

andypotter
  • 130
  • 6