Submit Form With Textfield With Value Set By Jquery


I have a textfieldrow with a value calculated a set by a jquery function.

To set the value i used $(’#textfieldrow_id’).val(calculated_value) and i try also with $(’#textfieldrow_id’).attr(‘value’, calculated_value). With both the calculated_value appears correctly in the textfieldrow.

The problem is when i try to submit the form.

This textfieldrow is a required field, and when i submit the form the validation returns always that the field needs to be set, so he doesn’t recognize the value set by the jquery function.

I checked the generated html and the input value is set.

Can anyone tell me why this happens?



I think u have not bind this textfield to form… please check that


i think i have.

in the view i have something like this: echo $form->textfieldrow($model_var, ‘model_field’, array(with options));

If i insert manually a value the submission is made correctly. Also i add the ‘model_field’ as safe in the model.

I find a solution:

In the view i had the following:

echo $form->textfieldrow($model_var, ‘model_field’, array(‘class’=>‘xpto’, ‘disabled’=>true)); .

So i replace the ‘disable’ property by the ‘readonly’.

echo $form->textfieldrow($model_var, ‘model_field’, array(‘class’=>‘xpto’, ‘readonly’=>true));

For this work i need also to add in the model rules the model field as safe.