Custom form within the Editor's edit template?

Custom form within the Editor's edit template?

marcoheuermarcoheuer Posts: 5Questions: 2Answers: 0

Hi -
I am trying to customize the editor's edit template with a custom search form that does a look up in another service, presents a list of results and allows the user to select one result. That result is then used to populate a value in a cell.

It's rendering fine and I see the proper event handlers.

The challenge is that there are two nested forms now: First the outer form from the DT Editor modal to capture the edited field(s). And then the inner form that I use to look up the values. When the inner form submits - to start the search to the external service - the submit event only is triggered on the outer form. Yes, the html spec does not specify nested forms and it seems bad form anyway.

What's the optimal way to move the inner form from the template as a sibling, ie same level as the editor's form element?
The structure is ".DTE_Action_Edit .modal-content" -> ".DTE_Body .modal-body" -> ".DTE_Body_Content" and then the form header, and form itself.

Or am I completely off-track and need to rethink the approach?

I am using DT Editor 2.0.6, if that matters.

Thank you for a great library and a thriving community!
Cheers,
Marco

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin

    Hi Marco,

    Do you need a form element at all for your search? It sounds like you are doing it entirely by Ajax, so you could just put a change or input listener on the search box (or a click event on a button, if you want the user to submit it). No need to wrap it in a form since you aren't doing a full page submit.

    Allan

  • marcoheuermarcoheuer Posts: 5Questions: 2Answers: 0
    edited May 2023

    Hi Allan -

    Sorry for the delay on my end. Thank you for the suggestion!

    The onclick for the submit button is what I am doing now. What is convenient with a form is the auto-submit when the user hits enter on the text input. There are some side effects with selecting from a browser's text input suggestions, but will work through it.

    Was hoping to keep it simple on my end and leverage ootb behaviours.

    It sounds there's no other way to avoid the nested forms with a custom template?

    Marco

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    Answer ✓

    What is convenient with a form is the auto-submit when the user hits enter on the text input.

    That should happen in Editor, as shown in this example.

    It sounds there's no other way to avoid the nested forms with a custom template?

    Nested form tags aren't supported in HTML at all I'm afraid (at least as far as I understand it).

    Allan

  • marcoheuermarcoheuer Posts: 5Questions: 2Answers: 0

    Yupp, the editing works in all the editors perfectly fine. I'll go the route of handling the search input interactions explicitly.

    Thanks, Allan. I'll mark this as answered.

Sign In or Register to comment.