CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Best practice for modifying client-side (JS) validation?
Pages: [1]

Author Topic: Best practice for modifying client-side (JS) validation?  (Read 434 times)

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Best practice for modifying client-side (JS) validation?
March 06, 2015, 08:02:20 am
I found a bug in the multisite module on CiviCRM 4.5, and could use some thought on how to fix this.

When multi-site is enabled, every group is required to have a parent group, so that field is set as required.  When Eileen's multisite extension is installed, it's desirable to remove that requirement - which she does with hook_validateForm.  In 4.4, that's fine, because there's only server-side validation.  In 4.5, a group "settings" page is validated client-side, and the hook doesn't fire.

What's the best approach here?  Should I just insert a Javascript file to replicate the hook logic?  Is there a better approach?
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Best practice for modifying client-side (JS) validation?
March 06, 2015, 08:10:32 am
The clientside validate logic is based on css classes. The field is getting the class "required" because quickform thinks it is required. Probably the cleanest and most semanticly pleasing solution would be to use a buildForm hook to make that field not required.
Try asking your question on the new CiviCRM help site.

JonGold

  • Ask me questions
  • ****
  • Posts: 638
  • Karma: 81
    • Palante Technology
  • CiviCRM version: 4.1 to the latest
  • CMS version: Drupal 6-7, Wordpress 4.0+
  • PHP version: PHP 5.3-5.5
Re: Best practice for modifying client-side (JS) validation?
March 06, 2015, 08:48:04 am
It sounds so obvious once you say it.  Thank you Coleman!
Sign up to StackExchange and get free expert CiviCRM advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Best practice for modifying client-side (JS) validation?

This forum was archived on 2017-11-26.