private function ViewsEFFieldsetData::recursiveTreeToFAPI in Views Exposed Form Fieldset 7
Parameters
$data:
$form:
array $element:
1 call to ViewsEFFieldsetData::recursiveTreeToFAPI()
File
- includes/
ViewsEFFieldsetData.php, line 101 - ViewsEFFieldsetData class file.
Class
- ViewsEFFieldsetData
- Class ViewsEFFieldsetData
Code
private function recursiveTreeToFAPI($data, &$form, &$element = array()) {
foreach ($data as $key => $item) {
// If it's a filter field
if ($item['item']['type'] == 'filter') {
$field_name = $form['#info']['filter-' . $item['item']['id']]['value'];
if (isset($form[$field_name]) && is_array($form[$field_name])) {
$element[$field_name] = $form[$field_name] + array(
'#weight' => $item['item']['weight'],
'#title' => $form['#info']['filter-' . $item['item']['id']]['label'],
);
if (!empty($form[$field_name]['#tree'])) {
$element[$field_name]['#type'] = 'fieldset';
}
unset($form['#info']['filter-' . $item['item']['id']]);
unset($form[$field_name]);
}
}
// If it's a sort field
if ($item['item']['type'] == 'sort') {
$field_name = $item['item']['id'];
if (isset($form[$field_name]) && is_array($form[$field_name])) {
$element[$field_name] = $form[$field_name];
$element[$field_name]['#weight'] = $item['item']['weight'];
unset($form[$field_name]);
}
}
// If it's the action buttons
if ($item['item']['type'] == 'buttons') {
$field_name = $item['item']['id'];
if (isset($form[$field_name]) && is_array($form[$field_name])) {
$element[$field_name] = $form[$field_name];
$element[$field_name]['#weight'] = $item['item']['weight'];
$form[$field_name]['#attributes']['style'][] = 'display:none;';
}
}
if (!empty($item['children']) && $item['item']['type'] == 'container') {
$element['container-' . $item['item']['id']] = array(
'#type' => $item['item']['container_type'],
'#title' => $item['item']['title'],
'#description' => $item['item']['description'],
'#collapsible' => (bool) $item['item']['collapsible'],
'#collapsed' => (bool) ($item['item']['collapsed'] || !empty($item['item']['collapsed_if_no_exposed_input']) && $this->view && !array_filter($this->view
->get_exposed_input())),
'#attributes' => array(
'class' => array(
'views-ef-fieldset-container',
'views-ef-fieldset-container-' . $item['item']['id'],
),
),
'#weight' => $item['item']['weight'],
);
$element['container-' . $item['item']['id']]['children'] = array();
$this
->recursiveTreeToFAPI($item['children'], $form, $element['container-' . $item['item']['id']]);
}
}
}