Yii Framework Forum: Yiibooster Textfield - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yiibooster Textfield Undefined variable: form Rate Topic: -----

#1 User is offline   Larry Jr. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 13-March 13
  • Location:Tomohon

Posted 12 July 2014 - 06:41 AM

Hi, since the previous topic has been locked, I tried to post new one.

I'm using YiiBooster and trying to make a textField within TbActiveForm inside the /views/layout/main.php
<?php $this->widget(
                'booster.widgets.TbActiveForm',
                array(
                    'id' => 'inlineForm',
                    'type' => 'inline',
                    'htmlOptions' => array('class' => 'well'),
                    )
                );
                echo $form->textFieldGroup($model, 'textField');
?>


But I have small problem, when tried to run it comes the error message:
PHP notice
Undefined variable: form

Attached File  undefined variable.png (34.11K)
Number of downloads: 5

I've already tried to make the mainController using gii, but still prompting the same error message.

Can anybody help me to fix this? Thanks.
JoenMarz
0

#2 User is offline   xexu 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 13-July 14

Posted 13 July 2014 - 12:15 PM

Hi, this error occurs because you're attempting to use a undefined variable (not declared yet). All you've to do is declare it before like this:

 $form = this->widget(
                'booster.widgets.TbActiveForm',
                array(
                    'id' => 'inlineForm',
                    'type' => 'inline',
                    'htmlOptions' => array('class' => 'well'),
                    )
                );


This will work as expected. Hope it can help you.
0

#3 User is offline   Larry Jr. 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 19
  • Joined: 13-March 13
  • Location:Tomohon

Posted 14 July 2014 - 07:02 AM

View Postxexu, on 13 July 2014 - 12:15 PM, said:

Hi, this error occurs because you're attempting to use a undefined variable (not declared yet). All you've to do is declare it before like this:

 $form = this->widget(
                'booster.widgets.TbActiveForm',
                array(
                    'id' => 'inlineForm',
                    'type' => 'inline',
                    'htmlOptions' => array('class' => 'well'),
                    )
                );


This will work as expected. Hope it can help you.


I added the textField inside of it:
 <?php $form = this->widget(
                'booster.widgets.TbActiveForm',
                array(
                    'id' => 'inlineForm',
                    'type' => 'inline',
                    'htmlOptions' => array('class' => 'well'),
                    )
                );
       // I added this line below, but the $model is undefined, how to do it?
       echo $form->textFieldGroup($model, 'textField');
       ?>


It almost work, only one more error message:

Quote

Undefined variable: model


How or where do I define the $model variable?

Thanks before
JoenMarz
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

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