function _oa_core_setup_node_space_type in Open Atrium Core 7.2
Alters a node edit form to setup the space_type/section_type functionality.
Parameters
array &$form: The Form API array that we are altering.
string $space_type: (Optional) The name of the taxonomy which contains the types.
string $field_name: (Optional) The field on the node which represents the current type.
2 calls to _oa_core_setup_node_space_type()
- oa_core_form_oa_space_node_form_alter in ./
oa_core.module - Implements hook_form_FORM_ID_alter().
- oa_sections_form_oa_section_node_form_alter in modules/
oa_sections/ oa_sections.module - Implements hook_form_FORM_ID_alter().
File
- ./
oa_core.module, line 1635
Code
function _oa_core_setup_node_space_type(&$form, $type = 'space_type', $field_name = 'field_oa_space_type') {
$selector = 'select[name="' . $field_name . '[und]"]';
$space_type = !empty($form[$field_name]['und']['#default_value']) ? $form[$field_name]['und']['#default_value'][0] : NULL;
$form['panelizer']['#states'] = array(
'visible' => array(
':input[name="field_oa_section_override[und]"]' => array(
'checked' => TRUE,
),
),
'invisible' => array(
':input[name="field_oa_section_override[und]"]' => array(
'checked' => FALSE,
),
),
);
$form['panelizer']['#access'] = TRUE;
$options = oa_core_get_space_type_options($type);
// Need to change array to string key for javascript
$js_options = array();
foreach ($options as $tid => $item) {
$js_options['tid' . $tid] = $item;
}
$form['#attached']['js'][] = array(
'data' => array(
'oaCoreSpaceTypeOptions' => $js_options,
'oaCoreSpaceTypeSelector' => $selector,
'oaCoreSpaceType' => $space_type,
),
'type' => 'setting',
);
$form['#attached']['js'][] = array(
'data' => drupal_get_path('module', 'oa_core') . '/js/oa_core_space_type.js',
'type' => 'file',
);
}