CMaskedTextField and Property is not defined error

I´m taking a problem using CMaskedTextField.

My view has many fields like this one:


<div class="row">

        <?php echo $form->labelEx($model, 'telefone_residencial'); ?>

        <?php

        $form->widget('CMaskedTextField', array(

            'model' => $model,

            'attribute' => 'telefone_residencial',

            'mask' => '(99)9999-9999',

            'htmlOptions' => array('size' => 30)

            ));

        ?>

        <?php echo $form->error($model, 'telefone_residencial'); ?>

</div>

And the model´s rules is defined like:


public function rules() {

        return array(

            array('telefone_residencial, telefone_celular, telefone_comercial', 'type', 'type' => 'string'),

        );

}

But when I run the application, the form is built incomplete and before it renders the field with cmaskedtextfield, it shows a message:

Telefone Residencial Property "Pessoa.telefone_residencial" is not defined.

What can it be?

:huh:

the error message has told you what 's going wrong . “Pessoa.telefone_residencial” is not defined"

the telefone_rsidencial is not defined in your model class "Pessoa" . if you extend the CActiveRecord the telefone_rsidencial

may be your table filed (do not need to define ) or define it as a public attribute of the Pessoa class (the field do not belong to the corresponding table ). if you extend the CFormModel the all fields using in your _form view should be defined

explicitly .

Hi Yiqing95, thanks for your help.

I´m extending from CActiveRecord and telefone_residencial is a table field from Pessoa Class.

But there is a weird thing about it.

When I run the application under an apache server in linux or windows xp occurs this error, but when I run the application under an apache for windows 7, the application runs normally.

And also, it just occurs when I use CMaskedTextField, if I change to a simple textfield, it works normally.