# This patch file was generated by NetBeans IDE # This patch can be applied using context Tools: Apply Diff Patch action on respective folder. # It uses platform neutral UTF-8 encoding. # Above lines and this line are ignored by the patching process. --- C:\wamp\www\sandbox\EmptyPHP.php +++ C:\wamp\www\sandbox\EmptyPHP_1.php @@ -288,6 +288,7 @@ if ($form['attributes']) { foreach ($form['attributes'] as $key => $value) { + if (is_array($form['attributes'][$key]) && $form['attributes'][$key]['#required'] == 1) { $attribute = uc_attribute_load($key, $product->nid, 'product'); $default_option = $attribute->default_option; @@ -296,13 +297,20 @@ $form['attributes'][$key]['#default_value'] = $default_option; } } + $form['attributes-'. $product->nid] = $form['attributes']; + + // We can't have this be required because customer may only need some of the multibuy items. - AW + $form['attributes-'. $product->nid][1]['#required'] = 0; unset($form['attributes']); } if ($product->type == 'donation') { //$form['donate_amount']['#default_value'] = 0; $form['donate_amount-'. $product->nid] = $form['donate_amount']; + + // We can't have this be required because customer may only need some of the multibuy items. - AW + $form['donate_amount-'. $product->nid]['#required'] = 0; unset($form['donate_amount']); } @@ -324,10 +332,17 @@ if (!is_numeric($donate_amount) || floatval($donate_amount) < 0) { form_set_error('donate_amount-'. $nid, t('You have entered an invalid amount.')); } + // Donate amount and description must both be set. - AW + if (floatval($donate_amount) > 0 && empty($form_state['values']['attributes-'. $nid][1])) { + form_set_error('attributes-'. $nid, t('Please enter a description.')); } + if (floatval($donate_amount) == 0 && !empty($form_state['values']['attributes-'. $nid][1])) { + form_set_error('donate_amount-'. $nid, t('Please enter a value.')); } } } + } +} function uc_multibuy_form_submit($form, &$form_state) { foreach($form_state['values'] as $key => $value) {