Hello there!
I have been playing with the AddressBook tutorial and to extend my exploration of Aida, I am trying to add field validation for Email input. I have been looking at the examples use in Aida and edited the code accordingly, but I still miss something. As I don't have proper report error, the validation code is working thought. My modifications are as follow: ADemoAddressBookApp>>editView [...] e addTextH1: 'Add/Edit the address'. self inError ifTrue: [e addText: self errorReport]. e cell addText: 'First name:'; addBreak. [...] e cell addText: 'Email:'; addBreak. field := e cell addInputFieldAspect: #email for: self observee. field validIfTrue: [ :value | value includes: $@ ]; errorText: [ 'Cela ne ressemble pas à un email' ]. e newCell add: field errorElement. [...] Then I changed actionEdit as follow self context form isValid ifFalse: [self showError: self context form collectErrorTexts. ^ self redirectToView: #edit ]. self redirectToView: #main The generated html code is like: <h1>Add/Edit the address</h1> aWebElement div id: error <table> <tbody><tr> <td>First name:<br> <input value="Sebastjan" name="field251" type="text"></td> </tr> <tr> <td>Last name:<br> <input value="Dormirtories" name="field252" type="text"></td> </tr> <tr> <td>Phone:<br> <input value="01/514 33 66" name="field253" type="text"></td> </tr> <tr> <td>Email:<br> <input value="[hidden email]" onchange="aidaEvent('change','id323','96679',document.getElementById('id323').value);; " name="field254" id="id323" type="text"></td> <td> <div comment="WebValidationError" id="id321" class="validationError"> <div comment="subform" id="id322"> </div> </div> </td> </tr> <tr> <td> #collectErrorTexts only procude '<br> string, so empty error message. What do I miss? Thanks Hilaire -- Dr. Geo - http://drgeo.eu iStoa - http://istoa.drgeo.eu _______________________________________________ Aida mailing list [hidden email] http://lists.aidaweb.si/mailman/listinfo/aida |
Ho my bad,
#errorText: argument is not a bloc but a string. field need to be sent #onChangePost message to get 'field errorElement' working. I have to admit it is pretty easy to use and I like that. Thanks Hilaire Le 17/02/2015 15:56, Hilaire a écrit : > Hello there! > > I have been playing with the AddressBook tutorial and to extend my > exploration of Aida, I am trying to add field validation for Email input. > I have been looking at the examples use in Aida and edited the code > accordingly, but I still miss something. As I don't have proper report > error, the validation code is working thought. > > My modifications are as follow: > > ADemoAddressBookApp>>editView > > [...] > > e addTextH1: 'Add/Edit the address'. > > self inError ifTrue: [e addText: self errorReport]. > > e cell > > addText: 'First name:'; > > addBreak. > > [...] > > e cell > > addText: 'Email:'; > > addBreak. > > field := e cell addInputFieldAspect: #email for: self observee. > > field > > validIfTrue: [ :value | value includes: $@ ]; > > errorText: [ 'Cela ne ressemble pas à un email' ]. > > e newCell add: field errorElement. > > [...] > > > Then I changed actionEdit as follow > > self context form isValid ifFalse: > > [self showError: self context form collectErrorTexts. > > ^ self redirectToView: #edit ]. > > self redirectToView: #main > > > > The generated html code is like: > > <h1>Add/Edit the address</h1> > aWebElement div id: error <table> > <tbody><tr> > <td>First name:<br> > <input value="Sebastjan" name="field251" type="text"></td> > </tr> > <tr> > <td>Last name:<br> > <input value="Dormirtories" name="field252" type="text"></td> > </tr> > <tr> > <td>Phone:<br> > <input value="01/514 33 66" name="field253" type="text"></td> > </tr> > <tr> > <td>Email:<br> > <input value="[hidden email]" onchange="aidaEvent('change','id323','96679',document.getElementById('id323').value);; " name="field254" id="id323" type="text"></td> > <td> <div comment="WebValidationError" id="id321" class="validationError"> > <div comment="subform" id="id322"> > </div> > </div> > </td> > </tr> > <tr> > <td> > > > > > #collectErrorTexts only procude '<br> string, so empty error message. > > What do I miss? > > Thanks > > Hilaire > -- Dr. Geo - http://drgeo.eu iStoa - http://istoa.drgeo.eu _______________________________________________ Aida mailing list [hidden email] http://lists.aidaweb.si/mailman/listinfo/aida |
Free forum by Nabble | Edit this page |