public function FillPdfFormForm::ajaxUpdateEntityId in FillPDF 5.0.x
Same name and namespace in other branches
- 8.4 src/Form/FillPdfFormForm.php \Drupal\fillpdf\Form\FillPdfFormForm::ajaxUpdateEntityId()
AJAX callback updating the 'default_entity_id' element.
This is triggered whenever either the default entity type is changed or another default entity ID is chosen. It replaces the 'default_entity_id' form element. If triggered by the 'default_entity_type' element, both the description and the autocomplete are reset, the latter being fed with referenceable entities of the chosen entity type. Otherwise, only the description is rebuilt reflecting the chosen default entity ID.
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 A render array containing the replacement form element.
File
- src/
Form/ FillPdfFormForm.php, line 470
Class
- FillPdfFormForm
- Form controller for the FillPDFForm edit form.
Namespace
Drupal\fillpdf\FormCode
public function ajaxUpdateEntityId(array &$form, FormStateInterface $form_state) {
$element = $form['default_entity_id'];
$triggering_element = reset($form_state
->getTriggeringElement()['#array_parents']);
if ($triggering_element == 'default_entity_type') {
unset($element['#value']);
}
return $element;
}