function button_field_form_field_ui_field_edit_form_alter in Button Field 7
Same name and namespace in other branches
- 8 button_field.module \button_field_form_field_ui_field_edit_form_alter()
Implements hook_form_FORM_ID_alter().
Hides the required and cardinality fields and removes the default value from the field_ui_field_edit_form because it does not apply to this field type.
File
- ./
button_field.module, line 278 - Defines a field, widget and formatter for the button field type.
Code
function button_field_form_field_ui_field_edit_form_alter(&$form, &$form_state, $form_id) {
if ($form['#field']['type'] == 'button_field') {
// Hide the required field and set it to false.
$form['instance']['required']['#type'] = 'hidden';
$form['instance']['required']['#value'] = FALSE;
// Hide the cardinality and set it to one.
$form['field']['cardinality']['#type'] = 'hidden';
$form['field']['cardinality']['#value'] = 1;
// No need for a default value.
unset($form['instance']['default_value_widget']);
}
}