Yii Framework Forum: Gii model generation not getting past first step - strange problem - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Gii model generation not getting past first step - strange problem $_POST['preview'] Not set Rate Topic: -----

#1 User is offline   apotter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 27-October 11
  • Location:Dortmund, Germany

Posted 09 January 2015 - 09:32 PM

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?
0

#2 User is offline   apotter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 27-October 11
  • Location:Dortmund, Germany

Posted 10 January 2015 - 03:25 PM

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.
0

#3 User is offline   apotter 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 27-October 11
  • Location:Dortmund, Germany

Posted 11 January 2015 - 11:25 AM

I've submitted pull request #6824
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users