I created a webform component and set the display to be "Disabled". the problem is that this option only add the "readonly" attribute to that textfield. If I remove that with firebug, the field becomes editable and the value can be changed. I don't want that. Any ideas on how I can achieve this?

In a hook_form_alter I tried

$form["submitted"]["field_name"]["#type"] = "value";


$form["#node"]->webform["components"][20]["type"] = "value";

but none of this works. Neither does $form["#after_build"][] = "afterbuild_function";


  • Have you tried submitting the form after being altered? – googletorp Jan 26 '12 at 15:23
  • Yes. If I change that value, the new value is saved in the database :( – Marius Ilie Jan 26 '12 at 15:27
  • 1
    Is the value always going to be the same? Or easily retrievable with code? Maybe you could add a custom submit handler that adds the value into the field on submission, that way even if the value has been changed, it will be changed back. – Chapabu Jan 26 '12 at 15:52
  • So it does, I would add this as an issue because I cant see this being desired behaviour. It should fall back on some server side validation – WestieUK Jan 26 '12 at 16:24
  • I'll probably have a different table in the database and use hook_form_alter after all... – Marius Ilie Jan 26 '12 at 16:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.