Yiibooster Textfield

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



5742

undefined variable.png

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.

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:

How or where do I define the $model variable?

Thanks before