You are here

function matrix_op in Matrix field 8.2

Same name and namespace in other branches
  1. 7.2 matrix.module \matrix_op()

Because the name attribute of the add more rows and add more columns is used $form_state['values']['op'] is not available. This function basically finds the op equivilent in $form_state

Parameters

$form_state: The form_state array

Return value

single array entry ofwith first element the name of the field and second element the value of the button

3 calls to matrix_op()
matrix_field_ajax_callback in ./matrix.module
AJAX callback Returns the field grid after the more rows or more cols button has been pressed
matrix_field_widget_validate in ./matrix.module
Form element validation handler. Respond to ajax requests and Reorder the data so that it is in the correct form for the fields api to save the data Each record gets its own delta. For multi-valued elements each value gets its own delta.
matrix_required_validate in ./matrix.module
Validate the required attribute of a cell standard #requied cannot be used because:

File

./matrix.module, line 623
Contains matrix.module.

Code

function matrix_op(&$form_state) {
  foreach ($form_state['values'] as $key => $value) {
    if (is_string($value) && strpos($key, 'matrix-button-') !== FALSE) {
      return array(
        substr($key, 14),
        $value,
      );
    }
  }
  return array(
    '',
    '',
  );

  //fallback case
}