I’ve obtained a type that submits by way of AJAX and in Drupal Development Service callback I have to rebuild sure components of Drupal Development Service web page to replicate Drupal Development Service newly submitted information. One in all these components is Drupal Development Service type, which I have to clear all person enter values from so it is prepared to make use of once more.
$response = new AjaxResponse(); // Take away all person submitted values $form_state->setValues( array() ); $form_state->setRebuild( TRUE ); // Construct a brand new occasion of Drupal Development Service type $form_object = Drupal::service('class_resolver')->getInstanceFromDefinition('Drupaltpl_projectFormMultiContactForm'); $form_object->setCompany( $company ); $replacement_form = Drupal::formBuilder()->buildForm( $form_object, $form_state ); // Substitute Drupal Development Service previous type with Drupal Development Service new one $response->addCommand(new HTMLCommand('.form-container', $replacement_form)); return $response;
When Drupal Development Service type is submitted it runs Drupal Development Service validation callback, Drupal Development Service submit handler, then calls Drupal Development Service above ajax handler. When it rebuilds Drupal Development Service type in Drupal Development Service above course of, it fires Drupal Development Service validation and submit handles once more, thus storing two data.
How can I stop this from taking place and nonetheless rebuild Drupal Development Service type to show no person enter all inside Drupal Development Service identical request?
Any assist drastically appreciated.