WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.8 is now available!


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Address form field not required?
  • Print
Pages: [1]   Go Down

Author Topic: Address form field not required?  (Read 8691 times)

Offline mgeene

  • Posts: 148
Address form field not required?
« 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!
Logged

Offline marmot

  • Posts: 1103
Re: Address form field not required?
« Reply #1 on: May 06, 2014, 09:01:55 PM »
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:
Code: [Select]
if ($field != 'cust_tax_no' && $field != 'cust_phone' && (strpos($field, 'company') === false)) { and delete or comment lines 139 - 144:
Code: [Select]
/*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
Logged

Offline mgeene

  • Posts: 148
Re: Address form field not required?
« Reply #2 on: May 06, 2014, 09:58:50 PM »
Hi,

THANKS! Thats it!
Logged

Offline seanie_morris

  • Posts: 301
  • Gender: Male
Re: Address form field not required?
« Reply #3 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.
Logged

Offline seanie_morris

  • Posts: 301
  • Gender: Male
Re: Zip field not required - can it be NOT required?
« Reply #4 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:
Code: [Select]
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:
Code: [Select]
if ($field != 'cust_tax_no' && $field != 'zip' && (strpos($field, 'company') === false)) {
and then commented line 159 as follows:
Code: [Select]
/*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.
Logged

Offline seanie_morris

  • Posts: 301
  • Gender: Male
Re: Address form field not required?
« Reply #5 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:

Code: [Select]
if ($field != 'cust_tax_no' && (strpos($field, 'company') === false) && (strpos($field, 'postcode') === false)) {
where 'postcode' is my substitute for 'zip'.

Yay!
Logged

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Bakery Shop »
  • Address form field not required?
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2