Sam Donato
Sam Donato

Reputation: 481

Primefaces file upload triggers required elements from a different form

I am using PrimeFaces 10 and I have a page with two different forms. One form is in a dialog:

 <p:dialog  widgetVar="myDlg" id="myDlg" modal="true" width="600">
    <h:form enctype="multipart/form-data" id="myDlgForm">
        <p:inputText id="myInput" value="#{myInput}" required="true">
    </h:form>
</p:dialog>

and there is a form on the page that has fileUpload

<h:form id="fileUploadForm" enctype="multipart/form-data">
    <p:messages id="messages" showDetail="false" closable="true">
        <p:autoUpdate/>
    </p:messages>
    <p:fileUpload listener="#{myFileUPloadView.handleFileUpload}" process="@this" mode="advanced" multiple="true" sizeLimit="1000000" fileLimit="6" widgetVar="fileUpload"/>
</h:form>

When I upload a file in fileUploadForm, I get the required message from the myInput input on myDlgForm. How can I prevent processing the dialog's form when I upload a file?

Upvotes: 1

Views: 136

Answers (1)

Sam Donato
Sam Donato

Reputation: 481

The issue was that I had two <p:remoteCommand's with the same name. Even though they were in different forms, they were both getting called which was triggering form validation on both forms.

Upvotes: 1

Related Questions