The module uses hook_form_alter() to add JS and CSS files to all webforms, irrespective of if they have some postcode lookup functionality configured.

This leads to the JS/CSS files being output for pages when they are not needed. We only want to add the JS/CSS when there is postcode lookup functionality configured for a webform on a page.

Comments

alex_sansom created an issue. See original summary.

alex_sansom’s picture

  • vijaycs85 committed b193b77 on 7.x-1.x authored by alex_sansom
    Issue #2886084 by alex_sansom: Prevent JS/CSS being added to webforms...
  • vijaycs85 committed c5cb328 on 7.x-1.x authored by alex_sansom
    Issue #2886084 by alex_sansom: Prevent JS/CSS being added to webforms...
vijaycs85’s picture

Thanks @alex_sansom. Committed.

diff --git a/includes/webform_captureplus.settings.class.inc b/includes/webform_captureplus.settings.class.inc
index 702eab6..5203607 100644
--- a/includes/webform_captureplus.settings.class.inc
+++ b/includes/webform_captureplus.settings.class.inc
@@ -55,7 +55,7 @@ class WebformCapturePlusSettings {
   public static function createFromNid($nid, $default_value = array()) {
     $key = WebformCapturePlusSettings::VARIABLE_PREFIX .$nid;
     $raw = variable_get($key, $default_value) +  array('fields' => array(), 'config' => array(), 'messages' => array());
-    if (is_array($raw['fields']) && !empty($raw['fields'])) {
+    if (!empty($raw['fields']) && is_array($raw['fields'])) {
       $object =  new static($raw['fields']);
       if (isset($raw['config'])) {
         $object->setConfig($raw['config']);

Just swapped the condition to check more of possibility at first :)

vijaycs85’s picture

Status: Active » Fixed
alex_sansom’s picture

Apologies Vijay. Updated patch attached.

Further testing on the initial patch revealed a problem with the 'Capture+' settings tab, giving errors when setting default form values.

vijaycs85’s picture

no problem. 50% my mistake that I didn't do any manual testing :) I'll do one with this patch later today. thanks.

  • vijaycs85 committed 9ed9126 on 7.x-1.x authored by alex_sansom
    Issue #2886084 by alex_sansom: Prevent JS/CSS being added to webforms...
vijaycs85’s picture

Status: Needs review » Fixed

Patch in #6 didn't apply. I have manually fixed and updated it.

vijaycs85’s picture

Version: 7.x-1.3-beta2 » 6.x-1.x-dev
Status: Fixed » Patch (to be ported)

We might need to back port to 6.x?

vijaycs85’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.