public function HierarchyManager::hierarchyGetNodeTypeSettingsForm in Entity Reference Hierarchy 8
Create the hierarchy type settings form, and load any default values using the configuration management settings.
Parameters
string $key: The name of the node type for which the form is being built.
bool $append_key: Append a node type where appropriate (almost always)
Return value
array The form array for the given hierarchy type.
Overrides HierarchyManagerInterface::hierarchyGetNodeTypeSettingsForm
See also
entity_hierarchy_form_node_type_edit_form_alter
File
- src/
HierarchyManager.php, line 114 - Contains \Drupal\entity_hierarchy\HierarchyManager.
Class
- HierarchyManager
- Defines a hierarchy manager.
Namespace
Drupal\entity_hierarchyCode
public function hierarchyGetNodeTypeSettingsForm($key, $append_key = FALSE) {
$config = \Drupal::config('entity_hierarchy.settings');
$form['nh_allowchild'] = array(
'#type' => 'checkboxes',
'#title' => t('Allowed child node types'),
'#options' => node_type_get_names(),
'#default_value' => $config
->get('nh_allowchild_' . $key),
'#description' => t('Node types which can be created as child nodes of this node type.'),
);
//$form['nh_defaultparent'] = _entity_hierarchy_get_parent_selector($key, $config->get('nh_defaultparent_'.$key));
// TODO: add default parent support later
//$form['nh_defaultparent']['#title'] = t('Default Parent');
// Todo: find out why this was removed in 7.x-4.x, and possibly remove from here and the Admin form.
// $form['nh_createmenu'] = array(
// '#type' => 'radios',
// '#title' => t('Show item in menu'),
// '#default_value' => $config->get('nh_createmenu_'.$key), //variable_get('nh_createmenu_' . $key, 'optional_no'),
// '#options' => array(
// 'never' => t('Never'),
// 'optional_no' => t('Optional - default to no'),
// 'optional_yes' => t('Optional - default to yes'),
// 'always' => t('Always'),
// ),
// '#description' => t("Users must have the 'administer menu' or 'customize entity_hierarchy menus' permission to override default options."),
// );
// Todo: implement this later
// $form['nh_multiple'] = array(
// '#type' => 'checkbox',
// '#title' => t('Allow multiple parents'),
// '#default_value' => $config->get('nh_multiple_'.$key),
// '#description' => t('Can nodes of this type have multiple parents?.'),
// );
$form['nh_defaultparent'] = $this
->hierarchyGetParentSelector($key, $config
->get('nh_defaultparent_' . $key, 0));
$form['nh_defaultparent']['#title'] = t('Default Parent');
// Would have preferred to handle this in the entity_hierarchy_views module, but not sure how
if (\Drupal::moduleHandler()
->moduleExists('entity_hierarchy_views')) {
$config = \Drupal::config('entity_hierarchy.settings');
$form['nh_default_children_view'] = array(
'#type' => 'select',
'#title' => t('Default Children View'),
'#multiple' => FALSE,
'#options' => _entity_hierarchy_views_view_options(),
'#required' => FALSE,
'#default_value' => $config
->get('nh_default_children_view_' . $key),
'#description' => t('Default for the embed children view feature.'),
);
}
// $form += \Drupal::moduleHandler()->invokeAll('entity_hierarchy_node_type_settings_form', array($key));
// If we need to append the node type key to the form elements, we do so.
if ($append_key) {
// Appending the key does not work recursively, so fieldsets etc. are not supported.
$children = \Drupal\Core\Render\Element::children($form);
foreach ($children as $form_key) {
$form[$form_key . '_' . $key] = $form[$form_key];
unset($form[$form_key]);
}
}
return $form;
}