Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC:

validating the values of a column using a table 10 Aug 2012 13:08 #3086

Is there way without COOK to validate the values of a field by using a table with the correct values.
p.e. I have a field CURRENCY and i want to make sure the value that is entered comes form a column CODE on my table, and that column contains 'EUR','USD',YEN',...

Please Log in or Create an account to join the conversation.

Re: validating the values of a column using a table 10 Aug 2012 13:15 #3087

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Very easy. (since jQuery validator)


TODO :
1. Add a js validator handler in helpers/html/validator.php ex : currency
2. Concat all these values to create a long regex. (can be generated dynamically by your component, better)
3. Create the languages strings associated (same file)
4. Add a class name to the field to validate : 'validate[currency]'

Note : to add a class to a JDom input :
..array(
...
"domClass" => 'validate[currency]'   // for the previous exemple
)..

Hope it helps.


EDIT : After reflexion, I think here it is better to do not use a SQL call to concat the currencies. It is a call each time the validator is instancied in the component, even if the form do not need this to validate.

So I would suggest a kind of cache file regenerated when the currencies are edited. Or eventually regenerated only if the validation is asked. (Coding only in this new component).

So the previous code is valid, but the regex is read from a file. Much better.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Last edit: by admin.

Re: validating the values of a column using a table 10 Aug 2012 13:27 #3088

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
Up, to notify the edition of the topic.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

Re: validating the values of a column using a table 10 Aug 2012 13:28 #3089

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 986
And I add that this validation is JS only.

With the coming of JForms (soon), you will be able to create a 'rule', which is a bridge between JS and PHP.
Coding is now a piece of cake

Please Log in or Create an account to join the conversation.

  • Page:
  • 1
Time to create page: 0.055 seconds

Freakin' Awesome!!! J-Cook is simply awesome - whether you're a highly experienced developer or complete novice whether you're building a small inventory component or a complete community solution! The beauty comes from a fast slick and reliable platform that readily provides developers with everything they'll need to build the backbone of a solid and secure component with wizards for authoring access publishing aliasing created/modified by dates... you name it COOK provides it! J-Cook really surpasses all of the 'competition' as far as MVC tools are concerned! Try love it and get cooking!
learnthrusong (JED)
          

Get Started