user_form_field_ui_field_edit_form_alter
function user_form_field_ui_field_edit_form_alter
user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id)
Implements hook_form_FORM_ID_alter().
Add a checkbox for the 'user_register_form' instance settings on the 'Edit field instance' form.
File
- modules/user/user.module, line 3771
- Enables the user registration and login system.
Code
function user_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) { $instance = $form['#instance']; if ($instance['entity_type'] == 'user' && !$form['#field']['locked']) { $form['instance']['settings']['user_register_form'] = array( '#type' => 'checkbox', '#title' => t('Display on user registration form.'), '#description' => t("This is compulsory for 'required' fields."), // Field instances created in D7 beta releases before the setting was // introduced might be set as 'required' and 'not shown on user_register // form'. We make sure the checkbox comes as 'checked' for those. '#default_value' => $instance['settings']['user_register_form'] || $instance['required'], // Display just below the 'required' checkbox. '#weight' => $form['instance']['required']['#weight'] + .1, // Disabled when the 'required' checkbox is checked. '#states' => array( 'enabled' => array('input[name="instance[required]"]' => array('checked' => FALSE)), ), // Checked when the 'required' checkbox is checked. This is done through // a custom behavior, since the #states system would also synchronize on // uncheck. '#attached' => array( 'js' => array(drupal_get_path('module', 'user') . '/user.js'), ), ); array_unshift($form['#submit'], 'user_form_field_ui_field_edit_form_submit'); } }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/modules!user!user.module/function/user_form_field_ui_field_edit_form_alter/7.x