public function Loader::getElementTypeInfo in Form Builder 7.2
1 call to Loader::getElementTypeInfo()
- Loader::getElement in src/
Loader.php - Get element instance.
File
- src/
Loader.php, line 53
Class
- Loader
- This class is a wrapper around all the hooks used for getting pluigns.
Namespace
Drupal\form_builderCode
public function getElementTypeInfo($form_type, $form_id) {
if (!isset($this->elementTypeInfo[$form_type][$form_id])) {
$element_types = module_invoke_all('form_builder_element_types', $form_type, $form_id);
$groups = $this
->getPaletteGroupInfo($form_type, $form_id);
// Add default values for undefined properties.
foreach ($element_types as $key => &$type) {
$type += array(
'class' => $this->formTypeInfo[$form_type]['element class'],
'configurable' => TRUE,
'removable' => TRUE,
'palette_group' => 'default',
'properties' => array(),
);
$type += array(
'addable' => $type['removable'] && isset($type['default']),
);
$type['unique'] = !empty($type['unique']);
$type['palette_group'] = isset($groups[$type['palette_group']]) ? $type['palette_group'] : 'default';
// All fields must support weight.
if (!in_array('weight', $type['properties'])) {
$type['properties'][] = 'weight';
}
// Update the default elements with some defaults.
// Note that if a field is not removable, it doesn't have a default.
$type['default'] += array(
'#form_builder' => array(),
);
if ($type['addable']) {
$type['default']['#form_builder'] += array(
'element_type' => $key,
);
if ($type['unique']) {
$type['default']['#form_builder']['element_id'] = $key;
}
}
}
// Sort fields by weight and title.
uasort($element_types, '_form_builder_sort');
drupal_alter('form_builder_element_types', $element_types, $form_type, $form_id);
$this->elementTypeInfo[$form_type][$form_id] = $element_types;
}
return $this->elementTypeInfo[$form_type][$form_id];
}