I would like to set a read only field in Drupal CiviCRM:
mymodule_civicrm_buildForm($formName, &$form) {
...
// Set default value
$defaults['readonly_field'] = xxx;
$form->setDefaults($defaults);
// Set read only
$element = $form->getElement('event_type_id');
$element->updateAttributes(array('disabled'=>true));
}
The field is disabled for input; however, the default value cannot be passed through the form submission.
The form warns that this required field does not input.
Could you advise how to set the read only field correctly?
Thanks a lot!!