#230 textarea custom field generates javascript error

Future_Requests
open
MRBS (195)
5
2015-02-27
2012-01-11
Neil Brown
No

MRBS 1.4.8 apache 2.2 php 5.1 mysql 5.0 Scientific Linux 5.6

After adding a new column to the "entry" and "repeat" tables (a varchar(80) in this case) to add a custom field to a booking, and then making it mandatory via
$is_mandatory_field['entry.contactinfo'] = TRUE;
in config.inc.php, MRBS generates the following PHP in the "validate()" function:

$.each(mandatory_fields,
       function(index, value)
       {
         var field = $("#"+value);
                      if ( ((field.attr('type').toLowerCase() == 'checkbox') && !field.attr('checked')) ||
              (field.val() == '') )
         {

The problem is the custom field generated is a <textarea> and that element does not have a "type" attribute, and javascript throws an error when the "Save" button is pressed. You'll probably not spot this error if all the mandatory fields were filled in, but if the required fields are not supplied you get taken to the "invalid booking" screen telling you about the missing field, but pressing "back" in your browser to correct the problem is likely to have thrown away any other changes that you made (though this does seem browser dependent)

I'll see if I can produce a patch to cater for the <textarea> case, but for now, just though I should let you know.

Neil

Discussion

  • Campbell Morrison

    Thanks for spotting this. I've fixed it in Rev 2241 by changing the condition to

             if ( ((field.attr('type') !== undefined) && 
                   (field.attr('type').toLowerCase() == 'checkbox') && 
                   !field.attr('checked')) ||
                  (field.val() == '') )
             {
    

    Campbell

     
  • John Beranek

    John Beranek - 2012-08-01
    • assigned_to: Campbell Morrison
    • milestone: --> Future_Requests
     
  • Comment has been marked as spam. 
    Undo

    You can see all pending comments posted by this user  here

    Anonymous - 2013-10-03

    m,.m.m,.m,.

     
  • Campbell Morrison

    OK - I'm taking a look.

    Campbell

     
  • Campbell Morrison

    Sorry - misread the thread. I see the original bug has been fixed, though at some stage in the future it would be nice to preserve the original form data in the event of an error, though you can only get to the error page if you have JavaScript disabled.

    Campbell

     
  • John Beranek

    John Beranek - 2015-02-27
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -13,8 +13,8 @@
                       (field.val() == '') )
                  {
    
    -The problem is the custom field generated is a <textarea> and that element does not have a "type" attribute, and javascript throws an error when the "Save" button is pressed. You'll probably not spot this error if all the mandatory fields were filled in, but if the required fields are not supplied you get taken to the "invalid booking" screen telling you about the missing field, but pressing "back" in your browser to correct the problem is likely to have thrown away any other changes that you made (though this does seem browser dependent)
    +The problem is the custom field generated is a &lt;textarea&gt; and that element does not have a "type" attribute, and javascript throws an error when the "Save" button is pressed. You'll probably not spot this error if all the mandatory fields were filled in, but if the required fields are not supplied you get taken to the "invalid booking" screen telling you about the missing field, but pressing "back" in your browser to correct the problem is likely to have thrown away any other changes that you made (though this does seem browser dependent)
    
    -I'll see if I can produce a patch to cater for the <textarea> case, but for now, just though I should let you know.
    +I'll see if I can produce a patch to cater for the &lt;textarea&gt; case, but for now, just though I should let you know.
    
     Neil
    
     


Anonymous

Cancel  Add attachments





Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks