3

When you want to hook into a CCK form and alter something, you are usually required to call a custom function from $form['#after_build'] (right?).

When doing so, I have noticed I can't write $form['field_name']['#disabled'] = TRUE; but instead I have to use the #attributes approach.

Why? Am I doing something wrong?

2

The form API is usually doing that for you, but it probably does that before calling the after_build functions.

The #after_build functions are called in form_builder(), #disabled handling is in _form_builder_handle_input_element(), which is called earlier in form_builder().

2
  • can i use #pre_render or #process instead of #after_build? would it make any difference? – Capi Etheriel Apr 11 '11 at 0:17
  • Not sure, some specific fields like those from date.module are only really built in #after_build functions, so you need to do your changes in such a callback too. Not sure about others. But if #pre_render works, you can probably also simply do your changes in hook_form_alter(). – Berdir Apr 11 '11 at 5:56

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.