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.084 seconds

I jumped and started to work on a demo component... but 2 days later this demo component became the real component. I just showed today the end result to my customer and he turned to me and said... "this is more than I expected"... All of this is because Cook did cut about 70% of my work and provided me more ways to improve the usability of the component. The end result was 17 tables all related between than to generate a full dashboard for the travel agents. Thanks for Cook developers for such great tool. This component would not be possible to be done at short time with all the features in it
Griiettner (Forum)  

Get Started