i'm currently working on a custom field/widget.

For a better ux i want to display some nested elements in a modal dialog. The elements are generated during form submission (multistep widget) i added a custom ajax callback like this: (For better understanding i reduced the code)

public static function myAjaxCallback(array $form, FormStateInterface $form_state) {
    $response = new AjaxResponse();

    $form['#attached']['library'][] = 'core/drupal.dialog.ajax';

      $button = $form_state->getTriggeringElement();
      $element = NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -3));

        new OpenModalDialogCommand('Only a few sub elements', $element, [])

      return $response;

The problem in this function is the elements are, obviously, rendered without a form around and so they can't get submitted.

Which would be the correct way to display only some nested elements in an ajax dialog?

Best regards Michael

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.