primefaces-extensions / primefaces-extensions.github.com

Organization repo, only for homepage, wiki and issue tracker
https://primefaces-extensions.github.io/
70 stars 22 forks source link

CreditCard: required attribute not working #790

Closed aripddev closed 4 years ago

aripddev commented 4 years ago

I have added required="true" for cardNumber, cardHolderName, expire and cvc inputs, but it does not trigger messages or growl.

Screen Shot 2020-04-29 at 02 18 47
melloware commented 4 years ago

You are right. Reproducible test case: pfe-790.zip

it looks related to having to to use the pt:name is no longer binding it to the component.

melloware commented 4 years ago

Yuck looks like this is the problem: https://stackoverflow.com/questions/15893876/how-to-specify-name-attribute-in-hinputtext

So using name="cvc" etc allow browsers to know these are autocomplete fields let the browser fill in your CC info and that is how Card.js default looks for those fields. However JSF needs the name field to bind to the backend.

Have to think about this...

melloware commented 4 years ago

OK got it working with this example: pfe-790.zip

You have to use prependId="false" on the form and make the id's the names instead of using passthrough.


<h:form prependId="false">
    <p:growl id="growl" showDetail="true" showSummary="true">
        <p:autoUpdate />
    </p:growl>
    <p:panelGrid id="pnlCreditCard" columns="4">
        <f:facet name="header">
            <pe:creditCard id="creditCard" labelMonthYear="MM/YY" placeholderExpiry="**/**" placeholderName="Optimus Prime"/>
        </f:facet>
        <p:inputText id="number" placeholder="Card number" required="true"/>
        <p:inputText id="name" placeholder="Full name"  required="true"/>
        <p:inputText id="expiry" placeholder="MM/YY"  required="true"/>
        <p:inputText id="cvc" placeholder="CVC"  required="true"/>
    </p:panelGrid>
    <p:commandButton value="Update" update="@form" process="@form" />
</h:form>
aripddev commented 4 years ago

Well done 👍, thanks

Screen Shot 2020-04-29 at 15 15 06
melloware commented 4 years ago

awesome