VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: bcohen0 on December 20, 2017, 04:31:43 AM

Title: Shopper fields: textarea does not respect "required" configuration VM 3.2.8
Post by: bcohen0 on December 20, 2017, 04:31:43 AM
Hi, I'm thinking this is a bug. If I create a textarea shopperfield for the user to fill out, and set it to required, it doesn't get the required class put on it, and it is never validated by the form validator. The shopper can leave it empty, then it fails at the server-side validation.  This is leaving the customer data on my site in an invalid state.

I am setting it to "required", "published", "show in account maintenance".

How/where does the required class get applied to the form fields? If someone could point this out, I could figure out why it doesn't work.
Title: Re: Shopper fields: textarea does not respect "required" configuration VM 3.2.8
Post by: bcohen0 on December 20, 2017, 05:49:08 AM
OK, it looks like a bug in    administrator/components/com_virtuemart/models/userfields.php   in function:   

   public function getUserFieldsFilled($_selection, &$_userDataIn = null, $_prefix = '')

.....
on or around line 989, change:
    case 'textarea':
                     $_return['fields'][$_fld->name]['formcode'] = '<textarea id="'
                     . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name . '" cols="' . $_fld->cols
                     . '" rows="'.$_fld->rows . '" class="inputbox" '
                     . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
                     . $readonly.'>'
                     . $_return['fields'][$_fld->name]['value'] .'</textarea>';
                     break;


to:

                  case 'textarea':
                     $_return['fields'][$_fld->name]['formcode'] = '<textarea id="'
                     . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name . '" cols="' . $_fld->cols
                     . '" rows="'.$_fld->rows . '" class="inputbox' .  ($_fld->required ? ' required "': '"' )
                     . ($_fld->maxlength ? ' maxlength="' . $_fld->maxlength . '"' : '')
                     . $readonly.'>'
                     . $_return['fields'][$_fld->name]['value'] .'</textarea>';
                     break;



The only difference between the two, is that $_fld->required is checked and added to the class list.  If this isn't in 3.2.10 already, can you please do this?
Title: Re: Shopper fields: textarea does not respect "required" configuration VM 3.2.8
Post by: Milbo on December 21, 2017, 11:27:58 AM
added, but a bit different class="inputbox'.($_fld->required ? ' required': '' ).'"