Just installed, enabled, and set up this module on one of my roles. When I view any items in my catalog, I get the following error message:
Notice: Undefined index: #value in uc_price_per_role_form_alter() (line 213 of /home1/xxx/public_html/xxx/test/sites/all/modules/uc_price_per_role/uc_price_per_role.module).

I'm not sure why this is showing up (aside from the obvious fact that $form['qty']['#value'] doesn't exist). There is a quantity field on the page, but nothing like it in $form.

To fix it, I just added an isset() to check if there is a '#value' index:

      if(isset($form['qty']['#value'])) {
	    $qty = intval($form['qty']['#value']);
	  }
      else {
        $qty = 1;
      }

Comments

goodeit’s picture

Title: Notice: Undefined index: #value in uc_price_per_role_form_alter() (line 213 of /home1/philthet/public_html/podiumcustom/test/sit » Notice: Undefined index: #value in uc_price_per_role_form_alter() (line 213 of uc_price_per_role.module)
pfrilling’s picture

I printed out the $form array and found that #value was changed to #default_value. The attached patch changes line #213 from

$qty = intval($form['qty']['#value']);

to

$qty = intval($form['qty']['#default_value']);
DanZ’s picture

Status: Needs work » Needs review
DanZ’s picture

Status: Needs review » Fixed

#value is correct. It might not be set when a new form is being altered if there is nothing in that form element yet.

Commited #0. Thanks!

Status: Fixed » Closed (fixed)

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