public function OrderForm::submitForm in Frequently Asked Questions 8
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 ConfigFormBase::submitForm
File
- src/
Form/ OrderForm.php, line 211
Class
- OrderForm
- Form for reordering the FAQ-s.
Namespace
Drupal\faq\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$order_no_cats = $form_state
->getValue('order_no_cats');
if ($form_state
->getValue('op')
->__toString() == t('Save order') && !empty($order_no_cats)) {
foreach ($order_no_cats as $i => $faq) {
$nid = $faq['nid'];
$index = $faq['sort'];
Database::getConnection()
->merge('faq_weights')
->fields(array(
'weight' => $index,
))
->keys(array(
'tid' => $form_state
->getValue('faq_category'),
'nid' => $nid,
))
->execute();
}
parent::submitForm($form, $form_state);
}
}