public function ReorderFolderForm::submitForm in Taxonomy File Tree 8
Same name and namespace in other branches
- 3.x src/Form/ReorderFolderForm.php \Drupal\tft\Form\ReorderFolderForm::submitForm()
Form submission handler.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides FormInterface::submitForm
File
- src/
Form/ ReorderFolderForm.php, line 193
Class
- ReorderFolderForm
- Term reordering form.
Namespace
Drupal\tft\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
foreach ($form_state
->getValue('table') as $key => $item) {
$name = $item['name'][2];
$pid = $item['parent'][0];
$tid = $item['parent'][1];
$weight = $item['weight'][0];
$term = Term::load($tid);
$term
->set('parent', [
'target_id' => $pid,
]);
$term
->setName($name);
$term
->setWeight($weight);
$term
->save();
}
}