public function FlexiformElementField::configureFieldSettingsForm in Flexiform 7
Add the Field Settings section to the config form.
We add this method separately as it allows us to pass our overridden field settings to the form, whereas field_ui_field_edit_form assumes field_info_field will provide the correct values.
Parameters
array $element: The Field Settings section of the form.
array &$form_state: The form state.
array $instance: Instance settings.
array $field: The field settings.
Return value
array The form element for the field settings.
1 call to FlexiformElementField::configureFieldSettingsForm()
- FlexiformElementField::configureForm in includes/
element/ field.element.inc - Overrides FlexiformElement::configureForm().
File
- includes/
element/ field.element.inc, line 214 - Contains FlexiformElementField class.
Class
- FlexiformElementField
- Class for Field API elements.
Code
public function configureFieldSettingsForm($element, $form_state, $field, $instance) {
$has_data = field_has_data($field);
// Create a form structure for the field values.
$element = array(
'#type' => 'fieldset',
'#title' => t('Field Settings'),
'#description' => t('These settings will override default Field API settings for this field. Overrides will only apply to this flexiform. <strong>Handle with care: Altering these settings can cause unexpected results.</strong>'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#tree' => TRUE,
);
// Build the configurable field values.
$description = t('Maximum number of values users can enter for this field.');
if (field_behaviors_widget('multiple values', $instance) == FIELD_BEHAVIOR_DEFAULT) {
$description .= '<br/>' . t("'Unlimited' will provide an 'Add more' button so the users can add as many values as they like.");
}
$element['cardinality'] = array(
'#type' => 'select',
'#title' => t('Number of values'),
'#options' => array(
FIELD_CARDINALITY_UNLIMITED => t('Unlimited'),
) + drupal_map_assoc(range(1, 10)),
'#default_value' => $field['cardinality'],
'#description' => $description,
);
// Add additional field type settings. The field type module is
// responsible for not returning settings that cannot be changed if
// the field already has data.
$additions = module_invoke($field['module'], 'field_settings_form', $field, $instance, $has_data);
if (is_array($additions)) {
$element['settings'] = $additions;
}
return $element;
}