# webform hidden component value

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";  and $form["#node"]->webform["components"][20]["type"] = "value";


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

Thanks

• 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
• 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