public function EntityCollector::submitForm in Relation 8
Same name and namespace in other branches
- 8.2 relation_entity_collector/src/Form/EntityCollector.php \Drupal\relation_entity_collector\Form\EntityCollector::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
- relation_entity_collector/
src/ Form/ EntityCollector.php, line 255 - Contains \Drupal\relation_entity_collector\Form\EntityCollector.
Class
- EntityCollector
- Provides a entity collector form.
Namespace
Drupal\relation_entity_collector\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$relation = _relation_entity_collector_get_entity();
if ($relation) {
array_multisort($form_state['values']['table']['weight'], SORT_ASC, $relation->endpoints[Language::LANGCODE_NOT_SPECIFIED]);
$relation
->save();
if ($relation
->id()) {
$link = \Drupal::l($relation->relation_type->entity
->label(), "relation/{$relation->id}()");
$list = _relation_stored_entity_keys_list();
$rendered_list = \Drupal::service('renderer')
->render($list);
$t_arguments = array(
'!link' => $link,
'!list' => $rendered_list,
);
if (isset($_SESSION['relation_edit'])) {
$message = t('Edited !link containing !list', $t_arguments);
}
else {
$message = t('Created new !link from !list', $t_arguments);
}
drupal_set_message($message);
relation_entity_collector_clear($form, $form_state);
}
else {
drupal_set_message(t('Relation not created.'), 'error');
}
}
}