WebsiteBaker Community Forum (upd)

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: mgeene on May 05, 2014, 10:09:51 PM

Title: Address form field not required?
Post by: mgeene on May 05, 2014, 10:09:51 PM
Hello,

Is it possible in the form where you must enter the delivery address that the telephone field is not required?

Thanks for your comment!
Title: Re: Address form field not required?
Post by: marmot on May 06, 2014, 09:01:55 PM
Hi,

if you are using bakery 1.6 read (maybe let google translate) this. (http://www.websitebaker.org/forum/index.php/topic,21975.0.html)
If you are using bakery 1.7 find in save_form.php line 34 and change to: if ($field != 'cust_tax_no' && $field != 'cust_phone' && (strpos($field, 'company') === false)) { and delete or comment lines 139 - 144: /*if (strpos($field, 'phone') !== false) {
if (!preg_match('#^[0-9)(xX +.-]{7,20}$#', $value)) {
$error_bg[] = $field;
$errors[]   = htmlspecialchars($value, ENT_QUOTES).' '.$MOD_BAKERY['ERR_INVAL_PHONE'];
}
}*/


regards
Title: Re: Address form field not required?
Post by: mgeene on May 06, 2014, 09:58:50 PM
Hi,

THANKS! Thats it!
Title: Re: Address form field not required?
Post by: seanie_morris on September 10, 2015, 02:33:42 PM
Hey there,

I've been pulling my hair out trying to replicate this but with a different field or fields. Take 'zip' or 'first_name' for examples, how would I make this work? I've tried so many combinations, even deleting or commenting the required section code further down (as was demonstrated in the phone field above) but I still get prompted about empty fields.

I had started a new post here:
http://forum.WebsiteBaker.org/index.php/topic,28630.0.html

but a search for something else turned up this older thread (which didn't come up on a search yesterday for me!)


Thanks in advance,

Seanie.
Title: Re: Zip field not required - can it be NOT required?
Post by: seanie_morris on August 23, 2016, 04:37:19 PM
((Using bakery 1.78, up from the previously mentioned 1.7 earlier in this thread))

I am chasing this up as I was never able to get the right code by trial and error, and it has come up for me again.

The following are accepted if the fields are left blank:
Line 42:
if ($field != 'cust_tax_no' && (strpos($field, 'company') === false)) {

How do I let 'zip' be accepted as well?

From the example in this thread, I changed line 42 to:
if ($field != 'cust_tax_no' && $field != 'zip' && (strpos($field, 'company') === false)) {

and then commented line 159 as follows:
/*if (strpos($field, 'zip') !== false) {
if (!preg_match('#^[A-Za-z0-9\s\-]{4,10}$#u', $value)) {
$error_bg[] = $field;
$errors[]   = htmlspecialchars($value, ENT_QUOTES).' '.$MOD_BAKERY['ERR_INVAL_ZIP'];
}
}*/


But I get errors that then will not display the form, so I have to undo all changes to get it back again.

Seanie.
Title: Re: Address form field not required?
Post by: seanie_morris on August 24, 2016, 06:55:09 PM
With a bit more trial and error (and a not-so-tired head), I managed to work it out:

if ($field != 'cust_tax_no' && (strpos($field, 'company') === false) && (strpos($field, 'postcode') === false)) {

where 'postcode' is my substitute for 'zip'.

Yay!