News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Shopper fields: textarea does not respect "required" configuration VM 3.2.8

Started by bcohen0, December 20, 2017, 04:31:43 AM

Previous topic - Next topic

bcohen0

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.

bcohen0

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?

Milbo

added, but a bit different class="inputbox'.($_fld->required ? ' required': '' ).'"
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/