WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Bakery Shop => Topic started by: sky writer on October 05, 2015, 04:58:24 AM

Title: Bakery 1.72 save_form.php breaking template issue
Post by: sky writer on October 05, 2015, 04:58:24 AM
Not sure if this is a bug or something specific to my template.  If a field in the checkout "Submit order: Address" form is left blank or filled with an invalid entry, the page reloads with the warning "The fields highlighted in red are blank. Please enter the required information.", but the error check adds an extra closing div which breaks the/my template.  I was able to fix this issue by commenting out two lines in the save_form.php file.

In save_form.php the two checks, one for blank, one for invalid field are:

line ~42
Code: [Select]
// If blank fields show error message
if (isset($blanks)) {
   $form_error = $MOD_BAKERY['ERR_FIELD_BLANK'];
   $error_bg = $blanks;
   extract($_POST);
   include('view_form.php');
   echo $end_of_wrapper;  // End of bakery wrapper
   return;
}

line ~150
Code: [Select]
// If any errors occured show address form again
if (@is_array($errors)) { 
   $form_error = '';
   foreach ($errors as $value) {
      $form_error .= $value.'<br />';
   }
   $form_error .= '<br />'.$MOD_BAKERY['ERR_INVAL_TRY_AGAIN'];
   include('view_form.php');
   echo $end_of_wrapper;  // End of bakery wrapper
   return;
}

I commented out the problem line in both instances, like so:
Code: [Select]
/* echo $end_of_wrapper;  // End of bakery wrapper */
The end_of_wrapper string is defined in the view.php file line~ 144
Code: [Select]
// Add a wrapper for Bakery to help with layout
echo "\n<div id='mod_bakery_wrapper_f'>\n";
$end_of_wrapper = "\n</div> <!-- End of bakery wrapper -->\n";

and when this is added, in my template anyway, it results in two instances of:
Code: [Select]
</div> <!-- End of bakery wrapper -->like so:
Code: [Select]
<script type='text/javascript'>
      <!--
      mod_bakery_toggle_s tate_f('CA', 'cust', 0);
      -->
   </script>
</div> <!-- End of bakery wrapper -->
</div> <!-- End of bakery wrapper -->
         <div class="clear">
         </div>
      </div>

I haven't found any issues arising from commenting out these lines, but others more knowledgeable may want to test it and comment.

Hope this helps.
Title: Re: Bakery 1.72 save_form.php breaking template issue
Post by: freeSbee on October 05, 2015, 01:00:24 PM
Hi sky writer

You are right. I was able to reproduce this and will fix it in the next version of Bakery. Thank you for the detailed bug report!

Regrads Christoph
Title: Re: Bakery 1.72 save_form.php breaking template issue
Post by: sky writer on October 05, 2015, 06:58:51 PM
Glad to help.
Title: Re: Bakery 1.72 save_form.php breaking template issue
Post by: cookiesfromhome on October 27, 2015, 08:50:22 AM
Nice post.Thanks for the information.