public function PanelsIPEBlockContentForm::submitAjax in Panels 8.4
Returns JSON in drupalSettings for our app to consume.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array An associative array containing the structure of the form.
File
- panels_ipe/
src/ Form/ PanelsIPEBlockContentForm.php, line 88
Class
Namespace
Drupal\panels_ipe\FormCode
public function submitAjax($form, FormStateInterface $form_state) {
$triggering_element = $form_state
->getTriggeringElement();
// Return early if there are any errors or if a button we're not aware of
// submitted the form.
if ($form_state
->hasAnyErrors() || $triggering_element['#name'] !== 'panels_ipe_submit') {
return $form;
}
// Inform the App that we've created a new Block Content entity.
if ($form_state
->getValue('is_new')) {
$form['#attached']['drupalSettings']['panels_ipe']['new_block_content'] = $this->entity
->uuid();
}
else {
$form['#attached']['drupalSettings']['panels_ipe']['edit_block_content'] = $this->entity
->uuid();
}
return $form;
}