Disabled text field

Disabled text field

by Abel Santos -
Number of replies: 0

Hello,

I have created a form in which I've got a text field. Depending on a checkbox I set the text field as disabled or enabled (to calculate the field or let the user write it). The textfield is a mandatory field, but when I set the disabled property to true, the edit.php i've created it's not getting the value (which I set by a instruction like this: document.getElementById("id_code").value = <value>, i see the value in the form on the screen).

Is there any way to make php recognise the value (even though the field is set to disabled).

Thanks.

        $mform->addElement('text', 'code', get_string('code', 'local'), array('size'=>'30'));
        $mform->addRule('code', get_string('required'), 'required', null);
        $mform->addElement('checkbox', 'calculatecode', get_string('calculatecode', 'local'),'','onClick="checkcontrol();" class="checkbox"');

There's a button in my form which is calculating the value that is presented in text "code".

Average of ratings: -