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.
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?
added, but a bit different class="inputbox'.($_fld->required ? ' required': '' ).'"