Drupal form alter remove cck field from form creation / editing form

What is the code to remove the display of the cck field from the page for creating / editing the content form?

+3
source share
2 answers

Set the field " #access" to " 0" or " FALSE".

For example, this removes the "Site mission" field on the site information page:

function example_form_system_site_information_settings_alter(&$form, &$form_state){
 $form['site_mission']['#access'] = 0;
}

(where "example" is the name of the custom module)


Another example: this time it removes the Sticky parameter from the page add / edit form:

function example_form_page_node_form_alter(&$form, &$form_state){
 $form['options']['sticky']['#access'] = 0;
}

You probably already know this, but you need to know the identifier (and structure) of the form you want to change.

hook_form_THEID_alter(&$form, &$form_state) , , hook_form_alter(&$form, $form_state, $form_id).


( Devel module), , , , .

function example_form_alter(&$form, $form_state, $form_id){
 echo "<h1>Form ID: $form_id</h1>";
 echo "Form Structure: <pre>".print_r($form, true)."</pre>";
}

( "example" - ).


, , .

+5

Source: https://habr.com/ru/post/1770020/


All Articles