Hi - have noticed with
2.0.24 that in the BT address form the required is missing for all the core fields except email (password, username etc)
tracked it down to administrator/components/com_virtuemart/models/userfields.php ~ line 506
//Small ugly hack to make registering optional //do we still need that? YES ! notice by Max Milbers
if($register && $type == 'BT' && VmConfig::get('oncheckout_show_register',1) ){
$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 0;
$field->value = '';
$field->default = '';
}
}
as I read this it sets all core field required to 0 therefore at the frontend e.g
Array
(
[name] => password2
[value] =>
[title] => Confirm Password
[type] => password
[required] => 0
[hidden] =>
[formcode] =>
[description] =>
)
if changed to
//Small ugly hack to make registering optional //do we still need that? YES ! notice by Max Milbers
if($register && $type == 'BT' && VmConfig::get('oncheckout_show_register',1) ){
$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 1;
$field->value = '';
$field->default = '';
}
}
everything works as expected
Array
(
[name] => password2
[value] =>
[title] => Confirm Password
[type] => password
[required] => 1
[hidden] =>
[formcode] =>
[description] =>
)
Cheers
Those fields are not required in VirtueMart account page because even guest users need to save their Bill To address who does not need to register. If you set these fields as required then guest checkout will not work in your site.
Ok - so not a bug - just an awful way of doing it..
then my answer is the same as in post http://forum.virtuemart.net/index.php?topic=119722.0 :)
But there are loads of posts asking why the validation and validation styling is so - well - quirky..
Cheers
Suggestions?
working on it... :)
Gruß
This seems to work fine - gives correct validation on must register and no problems on the other two cases
administrator/components/com_virtuemart/models/userfields.php ~ line 506
//Small ugly hack to make registering optional //do we still need that? YES ! notice by Max Milbers
if($register && $type == 'BT' && VmConfig::get('oncheckout_show_register',1) ){
$corefields = $this->getCoreFields();
unset($corefields[2]); //the 2 is for the email field, it is necessary in almost anycase.
if (!VmConfig::get ('oncheckout_only_registered', 0)) {
foreach($userFields as $field){
if(in_array($field->name,$corefields)){
$field->required = 0;
$field->value = '';
$field->default = '';
}
}
}
}
administrator/components/com_virtuemart/models/userfields.php ~ line 861
case 'password':
case 'password2':
$_return['fields'][$_fld->name]['formcode'] = '<input type="password" id="' . $_prefix.$_fld->name . '_field" name="' . $_prefix.$_fld->name .'" '.($_fld->required ? ' class="required"' : ''). ' size="30" class="inputbox" />'."\n";
break;
[attachment cleanup by admin]
Thanks!! Really helped me!!