How To Pass A Cform To A Widget

Hi guys, help me please

I have the following code containing mobile phone field in my view file:


<?php echo $form->textFieldControlGroup($model,'mobile_phone',array('span'=>3,'maxlength'=>255)); ?>

But I want to use widget WHPhone from yiiwheels, so I want my mobibe_phone field containing the mask. I am using widget:


$this->widget('yiiwheels.widgets.formhelpers.WhPhone',array(

                'name' => 'mobile_phone',

                'value' => 'Телефон',

                'format' => '+7 (ddd) ddd-dddd',

                'model' => $model,

            ));

But it doesn’t work. It doesn’t save data. I am doing smth wrong. Is it right to pass a model through ‘model’=>$model in widget or not? And what shall I do to let my mask phone field work correctly using widget? Where to pass a model in widget?

Thanks in advance

Hey @v.r.

Try this instead:




$this->widget('yiiwheels.widgets.formhelpers.WhPhone',array(

                'attribute' => 'mobile_phone',

                'value' => 'Телефон',

                'format' => '+7 (ddd) ddd-dddd',

                'model' => $model,

            ));



Notice that you should not use the ‘name’ property when working with a model and using a widget. Instead use the ‘attribute’ property.

If you explicitly set the ‘name’ property and you are using a model, then when the widget is created it won’t generate the correct name and id values for the input control.

Hope this helps.

Regards,