What’s the code to remove the display of a cck field from a content-type create/edit form page?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Set the “
#access” field to “0” or “FALSE“.For example, this removes the “Site mission” field from the site informations page:
(where “example” is the name of a custom module)
Another example, this time it removes the Sticky option from add/edit page form:
You probably know that already, but you will need to know the id (and the structure) of the form you wish to alter.
Most of the time,
hook_form_THEID_alter(&$form, &$form_state)is the good place to modify a specific form, however some fields are created after this hook is called, so in such cases, you need to use the generichook_form_alter(&$form, $form_state, $form_id)instead.If you don’t know the structure or even the form id (and don’t want to install the Devel module), you could use this snipplet, so that when you’re viewing the page you want to modify, it will display the form id and its structure at the top of the page.
(where “example” is the name of your custom module).
By the way, if you’re just trying to prevent regular users from editing admin-only fields, you could simply use the Field Permissions module instead.