Address form field not required?

seanie_morris

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!

seanie_morris

((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.

seanie_morris

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.

mgeene


marmot

Hi,

if you are using bakery 1.6 read (maybe let google translate) this.
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

mgeene

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!