function ds_shared_form in Display Suite 7
Same name and namespace in other branches
- 7.2 modules/ds_ui/includes/ds.fields.inc \ds_shared_form()
Shared form for all all fields.
4 calls to ds_shared_form()
- ds_edit_block_field_form in ./
ds.fields.inc - Manage a custom block.
- ds_edit_ctools_field_form in ./
ds.fields.inc - Manage a CTools field.
- ds_edit_custom_field_form in ./
ds.fields.inc - Manage a custom field.
- ds_edit_preprocess_field_form in ./
ds.fields.inc - Manage a Preprocess field.
File
- ./
ds.fields.inc, line 119 - Administrative functions for managing custom fields for every entity.
Code
function ds_shared_form(&$form, $field) {
ctools_include('export');
$custom_fields = ctools_export_crud_load_all('ds_fields');
if (isset($custom_fields[$field])) {
$field = $custom_fields[$field];
}
else {
$field = new stdClass();
$field->label = '';
$field->field = '';
$field->entities = array();
$field->properties = array();
}
$form['name'] = array(
'#title' => t('Label'),
'#type' => 'textfield',
'#default_value' => $field->label,
'#description' => t('The human-readable label of the field.'),
'#maxlength' => 32,
'#required' => TRUE,
'#size' => 30,
);
$form['field'] = array(
'#type' => 'machine_name',
'#default_value' => $field->field,
'#maxlength' => 32,
'#description' => t('The machine-readable name of this field. This name must contain only lowercase letters and underscores. This name must be unique.'),
'#disabled' => !empty($field->field),
'#machine_name' => array(
'exists' => 'ds_field_unique',
),
);
$entity_options = array();
$entities = entity_get_info();
foreach ($entities as $entity_type => $entity_info) {
if (isset($entity_info['fieldable']) && $entity_info['fieldable'] || $entity_type == 'ds_views') {
$entity_options[$entity_type] = drupal_ucfirst(str_replace('_', ' ', $entity_type));
}
}
$form['entities'] = array(
'#title' => t('Entities'),
'#description' => t('Select the entities for which this field will be made available.'),
'#type' => 'checkboxes',
'#required' => TRUE,
'#options' => $entity_options,
'#default_value' => $field->entities,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 100,
);
// Validate & submit are also the same.
$form['#validate'][] = 'ds_shared_form_validate';
$form['#submit'][] = 'ds_shared_form_submit';
return $field;
}