I just installed Webform Matrix Component 7.x-4.16 for a multi-page webform project and immediately received notices and warning errors when visiting the page containing the matrix I had added on the webform. Here's what I have installed as well as steps to reproduce the errors:

INSTALLS

Drupal 7.39
Webform 7.x-4.10
Webform Matrix Component 7.x-4.16

STEPS TO CREATE MATRIX

1) Add a textbox field = Company Name (field = company_name)

2) Add a pagebreak

3) Add a matrix field with these properties:
Label = Units
Field Key = units
Matrix Rows = 2
Matrix Column = 5
element-1
- Title = Year
- Label Name 1 = Number of Units
- Label Name 2 = Average Occupancy
element-2
Field type = Textfield
Title = 2011
Mandatory = unchecked
Textfield and Maxlength = 50
element-3
Field type = Textfield
Title = 2012
Mandatory = unchecked
Textfield and Maxlength = 50
element-4
Field type = Textfield
Title = 2013
Mandatory = unchecked
Textfield and Maxlength = 50
element-5
Field type = Textfield
Title = 2014
Mandatory = unchecked
Textfield and Maxlength = 50

4) Add a pagebreak

5) Add a textbox field = Comments (field = comments)

6) Save the webform, click "View" tab and go through the Next buttons to the matrix to see these errors:

Notice: Undefined offset: 1 in webform_matrix_component_form_alter() (line 287 of \sites\all\modules\webform_matrix_component\webform_matrix_component.module).
•Notice: Undefined offset: 1 in webform_matrix_component_form_alter() (line 287 of \sites\all\modules\webform_matrix_component\webform_matrix_component.module).
•Notice: Undefined offset: 1 in webform_matrix_component_form_alter() (line 287 of \sites\all\modules\webform_matrix_component\webform_matrix_component.module).
•Notice: Undefined offset: 1 in webform_matrix_component_form_alter() (line 287 of \sites\all\modules\webform_matrix_component\webform_matrix_component.module).

Warning: Invalid argument supplied for foreach() in webform_matrix_component_form_alter() (line 281 of \sites\all\modules\webform_matrix_component\webform_matrix_component.module).

Comments

jayhawkfan75 created an issue. See original summary.

katannshaw’s picture

Title: Webform 7.x-4.10 + WMC 7.x-4.16 Causes Errors » Webform 7.x-4.10 + WMC 7.x-4.16 + Pagebreak = Errors

In further testing I removed the pagebreaks from the form and the errors went away so this seems to be caused specifically with the combination of Webform matrix component fields + Webform pagebreak fields in my case. is anyone else experiencing this behavior?

fibie’s picture

I had this error as well with

Drupal 7.41
Webform 7.x-4.12
Webform Matrix Component 7.x-4.x-dev

I rolled it back to Webform 7.x-4.10 and it resolved the issue I think.

Something must have changed within the webform component?

chetan-singhal’s picture

Status: Active » Closed (cannot reproduce)

can someone verify

andjsmit’s picture

I ran into this issue today. After installing WMC (7.x-4.22) using Webform 7.x-4.12 and adding a matrix to an existing multi-page form, going to the page causes LOTS of the following message:

Notice: Undefined index: 1 in webform_matrix_component_form_alter() (line 301 of [REDACTED]/sites/all/modules/webform_matrix_component/webform_matrix_component.module).
andjsmit’s picture

Status: Closed (cannot reproduce) » Active
andjsmit’s picture

Quick "fix" which doesn't appear to harm the form submissions starting at line 293 of webform_matrix_component.module :

                  case 'label':
                    // Label markup can be different on each row so we neeed to loop through each label.
                    foreach($elevalue['label_name'] as $delta => $label_element) {
                      $default_value = (!empty($editvalue[$prow][$i])) ? $editvalue[$prow][$i] :	'';
                      $element[$prow][$i][$delta] = array(
                        '#type' => 'item',
                        '#title' => check_plain($title),
                        '#markup' => webform_filter_xss($label_element),
			'#attributes' => array('class' => array('form-item')),
                        '#default_value' => $default_value,
                        '#title_display' => $title_display,
                      );
                      $element[$prow][$i]['#webform_matrix_component_labels'] = TRUE;
                    }
chetan-singhal’s picture

try to resave your form. I think you will not get error.

chetan-singhal’s picture

Status: Active » Closed (cannot reproduce)