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

Real time saver and great Component Builder tool ! I have been developing with J-Cook Pro Component Builder for several months now and can say with all honesty that this product/service is second to none. The product is feature rich and is being improved and added to all the time. Do yourself a favor if you need to build a Joomla! Component then you can do no wrong in trying the product. You will save on time and effort while being able to deliver your project on time. J-Cook pro does the hard work for you you then have the freedom to fully customise the end result for your own needs. 

One word: Awesome.
Edwardcox (JED)
         

Get Started