function conditional_fields_content_admin_field_controllable in Conditional Fields 6.2
Same name and namespace in other branches
- 6 conditional_fields.module \conditional_fields_content_admin_field_controllable()
Controllable field settings form
2 calls to conditional_fields_content_admin_field_controllable()
- conditional_fields_content_admin_field in ./
conditional_fields.module - Alteration of the field editing form
- conditional_fields_fieldgroup_group_edit_form in ./
conditional_fields.module - Alteration of the fieldgroup editing form
File
- ./
conditional_fields.module, line 487 - Content fields and groups visibility based on the values of user defined 'trigger' fields.
Code
function conditional_fields_content_admin_field_controllable($type, $default_values, $available_fields, $allowed_values, $context) {
$output = array(
'#type' => 'fieldset',
'#title' => t('Controlling fields'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
'#description' => '<p>' . t('Choose which allowed values of available controlling fields will trigger this @context, making it visible both in node editing and view. If the <em>- Not controlling -</em> option or no option is selected, the @context will be always visible. If the <em>- None (empty value) -</em> option is selected, the controlled field will be visible only when the controlling field has no value. Only fields with <em>Allowed values</em> set are available for control. If a field is inside a controlled group, it can control or be controlled only by fields in the same group.', array(
'@context' => $context,
)) . '</p>',
);
// Create selection lists
foreach ($available_fields as $field) {
$allowed_values[$field['field_name']] = array(
'conditional_field_no_value' => t('- Not controlling -'),
) + $allowed_values[$field['field_name']];
if (!empty($default_values[$field['field_name']])) {
$default_value = $default_values[$field['field_name']];
}
else {
$default_value = 'conditional_field_no_value';
}
$output[$field['field_name']] = array(
'#type' => 'select',
'#multiple' => TRUE,
'#title' => $field['widget']['label'] . ' (' . $field['field_name'] . ')',
// To do: set right url for groups
'#description' => t('<a href="@edit-field">Edit the allowed values</a> of %field-name.', array(
'@edit-field' => url('admin/content/node-type/' . $type['url_str'] . '/fields/' . $field['field_name'], array(
'query' => 'destination=admin/content/node-type/' . arg(3) . '/' . arg(4) . '/' . arg(5),
)),
'%field-name' => $field['field_name'],
)),
'#options' => $allowed_values[$field['field_name']],
'#default_value' => $default_value,
);
}
return $output;
}