If I a UC Webform Pane with a select option - where multiple options are available but not mandatory (checkboxes), let's say A, B and C, when I open the order edit window, I can *change* the webform options (A=>B, B=>A+B), but it's not possible to unselect all the options (A=>none selected) and have the webform changed when the order is saved - it just ignores the changes and retains the old data.

I noticed this because I have a webform select options with a single option "yes" - as a multiple checkbox (that can be turned on and off - the only way to do this in webforms as far as I can tell.). I can't uncheck yes in the order edit window and have to dig down to find the webform submission to change it.

I'm going to try a little code digging to see what's going on here.

Comments

TrevorBradley’s picture

OK, I've tracked this down.

uc_webform_pane.module: _uc_webform_pane_save: line 463

    // Clean up empty values as these won't be saved anyway
    if (is_array($value) && sizeof($value) == 0) {
      unset($form_state['values']['submitted'][$key]);
    }

I've compared webform_client_form_submit for both this artificial $form_state and the one submitted by actually editing the webfom. The non mandatory select field actually requires an empty array to be submitted for the values to be removed, e.g.

$form_state['values']['submitted'][6] = array();

rather than be excluded - which doesn't alter the existing data. I *want* to save empty data.

If I remove these three lines, the Order Edit page behaves as it should.

I've made my own copy of of _uc_webform_pane_save in my own custom _uc_webform_order_pane_NID() code for now, but it would be cool to see this fixed in a future release!

I'd submit a patch removing these lines, but I'm sure they're in there for some reason - it would be best to figure out why they're there in the first place before removing them for everyone else..