Cannot submit form on pop up window liferay

659 Views Asked by At

I cannot figure out why it won't submit the form and it will just skip over in closing the pop up. I have tried other solutions but failed so.

My first problem encountered was after submitting, it will load on the same pop up window, not on parent portlet and will not close the pop up after submitting. I was able to solved on closing the pop up when submit button is clicked but It will not submit the form.

Inside the pop up modal:

<form action="<%= actionURL %>" id="formModal" name="formModal">
        // all input fields here
    <button name="submitBtnModal" id="submitBtnModal" type="submit">
</form>

<aui:script use="liferay-util-window">
    A.one('#submitBtnModal').on('click', function(event) {
        document.formModal.submit();  // cannot submit form
        Liferay.Util.getOpener().closePopup('closedialog'); // will proceed to close pop up
         Liferay.Util.getOpener().refresh(); // can refresh parent page
    });
</aui:script>

Solutions tried but doesn't work:

  1. Changed from <form> to <aui:form>

  2. Changed type to button and add a javascript function onSubmitModal() when onclick Submit button.

    function onSubmitModal(){ document.getElementById("formModal").submit(); }

  3. Tried to add javascript function inside <aui:script>

There is no problem on the back end as I debugged it. There was no error too on the logs. It is just that it wont submit and cannot call the <%= actionURL => in the form.

I cannot figure out why it still wont submit the form after all those solutions that I have tried.

My expected result is after submitting form, it will call <%= actionURL %>, get all those input fields data and after close the pop up and refresh parent page.

Update: I have already solved this issue. Thank you for people who tried to help. I will post my solution later for others reference.

0

There are 0 best solutions below