Form constructor for adding and editing forum containers.
\Drupal\taxonomy\Plugin\Core\Entity\Term $term: A container term to be edited.
function forum_form_container($form, &$form_state, Term $term) {
$config = config('forum.settings');
// Handle a delete operation.
$form['name'] = array(
'#title' => t('Container name'),
'#type' => 'textfield',
'#default_value' => $term->name->value,
'#maxlength' => 255,
'#description' => t('Short but meaningful name for this collection of related forums.'),
'#required' => TRUE,
);
$form['description'] = array(
'#type' => 'textarea',
'#title' => t('Description'),
'#default_value' => $term->description->value,
'#description' => t('Description and guidelines for forums within this container.'),
);
$form['parent']['#tree'] = TRUE;
$form['parent'][0] = _forum_parent_select($term
->id(), t('Parent'), 'container');
$form['weight'] = array(
'#type' => 'weight',
'#title' => t('Weight'),
'#default_value' => $term->weight->value,
'#description' => t('Containers are displayed in ascending order by weight (containers with equal weights are displayed alphabetically).'),
);
$form['vid'] = array(
'#type' => 'hidden',
'#value' => $config
->get('vocabulary'),
);
$form['actions'] = array(
'#type' => 'actions',
);
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#button_type' => 'primary',
'#submit' => array(
'forum_form_submit',
),
);
if (!$term
->isNew()) {
$form['actions']['delete'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
'#submit' => array(
'forum_forum_delete',
),
);
$form['tid'] = array(
'#type' => 'value',
'#value' => $term
->id(),
);
}
$form['#theme'] = 'forum_form';
return $form;
}