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 (Moderator: Donald Lobo) »
  • Value of disabled field is treated as empty
Pages: [1]

Author Topic: Value of disabled field is treated as empty  (Read 880 times)

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Value of disabled field is treated as empty
April 12, 2012, 06:35:16 pm
I added a bit of JavaScript to the CiviContribute page, that impacts the form fields for automatic recurring contributions.  My code changes the value of the field for "interval" to either 1 , 3, or 6 ( to cover monthly, quarterly, or semi-annuall payment schedules).  My code also sets the field to "disabled" so that the end-user cannot change the value to anything else.

However,  the form validation seems convinced that the field is not filled in, as I get the following message on submission:
Please enter a number for how often you want to make this recurring contribution (EXAMPLE: Every 3 months).

If I change the JavaScript to just fill in the number, but not disable the field then the issue does not occur.   Any ideas on an approach that would prevent the user from changing the number yet allow the form to be submited?
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

lcdweb

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1620
  • Karma: 116
    • www.lcdservices.biz
  • CiviCRM version: many versions...
  • CMS version: Joomla/Drupal
  • MySQL version: 5.1+
  • PHP version: 5.2+
Re: Value of disabled field is treated as empty
April 12, 2012, 06:58:26 pm
that's actually an html problem more than a js problem. a disabled form input element is ignored by the form. i think that's the actual definition of a disabled element.

i think if you disable the containing div it doesn't impact the form element. you just can't make the element itself (<input>) disabled. or you could could try cj("#myelement").attr('visibility','hidden') -- which should work
support CiviCRM through 'make it happen' initiatives!
http://civicrm.org/mih

SarahG (FountainTribe)

  • Ask me questions
  • ****
  • Posts: 782
  • Karma: 29
  • CiviCRM version: 4.4.7
  • CMS version: Drupal 6, Drupal 7
  • MySQL version: 5.5
  • PHP version: 5.3
Re: Value of disabled field is treated as empty
April 12, 2012, 07:24:06 pm
I found a decent solution- I made the fields read-only.  In this case I do want the user to see the fields, just not make changes.
Did I help you? Please donate to the Civi-Make-It-Happen campaign  CiviCRM for mobile devices! 

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Value of disabled field is treated as empty

This forum was archived on 2017-11-26.