View source
<?php
module_load_include('inc', 'webform_matrix_component', '/components/matrix');
module_load_include('inc', 'webform', '/includes/webform.components');
function webform_matrix_component_menu() {
$items['webform_matrx_component/get-type-option'] = array(
'page callback' => '_webform_matrix_component_get_type_option',
'access callback' => TRUE,
'file' => 'matrix.inc',
'type' => MENU_CALLBACK,
'file path' => drupal_get_path('module', 'webform_matrix_component') . '/components',
);
return $items;
}
function webform_matrix_component_webform_component_info() {
$components = array();
$components['matrix'] = array(
'label' => t('Matrix'),
'description' => t('Basic matrix type. Add One More Element in Row'),
'features' => array(
'default_value' => FALSE,
'description' => TRUE,
'title' => TRUE,
'title_display' => TRUE,
'title_inline' => FALSE,
'conditional' => TRUE,
'group' => FALSE,
'csv' => TRUE,
),
'file' => 'components/matrix.inc',
'file path' => drupal_get_path('module', 'webform_matrix_component'),
);
return $components;
}
function webform_matrix_component_form_webform_component_edit_form_alter(&$form, &$form_state) {
if ($form['type']['#value'] == 'matrix') {
$nid = arg(1);
$node = node_load($nid);
$component = $node->webform['components'][1];
$matrix_form = _webform_matrix_component_get_column_form($form, $form_state, $component);
$form = array_merge($form, $matrix_form);
$form['actions']['submit']['#submit'][] = 'webform_component_edit_form_matrix_submit';
$form['actions']['submit']['#validate'][] = 'webform_component_edit_form_matrix_validate';
$form['#validate'][] = 'webform_component_edit_form_matrix_validate';
}
}
function webform_component_edit_form_matrix_validate(&$form, &$form_state) {
if (!empty($form_state['ahah_submission'])) {
$form['#validate'] = $form['actions']['submit']['#validate'] = array();
return;
}
}
function webform_component_edit_form_matrix_submit($form, &$form_state) {
if (!empty($form_state['ahah_submission'])) {
return;
}
}
function webform_matrix_component_form_webform_admin_settings_alter(&$form, &$form_state, $formid) {
module_load_include('inc', 'webform', 'components/number');
$form['matrix_fieldset'] = array(
'#type' => 'fieldset',
'#title' => t('Matrix Component Settings'),
'#collapsible' => 1,
'#collapsed' => 1,
);
$form['matrix_fieldset']['webform_matrix_component_webform_matrix_rows'] = array(
'#type' => 'textfield',
'#title' => t('Matrix Rows'),
'#description' => t('Enter the max rows in matrix component'),
'#default_value' => variable_get('webform_matrix_component_webform_matrix_rows', 10),
'#element_validate' => array(
'_webform_validate_number',
),
'#integer' => TRUE,
'#min' => 1,
'#max' => 100,
'#step' => 1,
);
$form['matrix_fieldset']['webform_matrix_component_webform_matrix_cols'] = array(
'#type' => 'textfield',
'#title' => t('Matrix Cols'),
'#description' => t('Enter the max cols in matrix component'),
'#default_value' => variable_get('webform_matrix_component_webform_matrix_cols', 10),
'#element_validate' => array(
'_webform_validate_number',
),
'#integer' => TRUE,
'#min' => 1,
'#max' => 100,
'#step' => 1,
);
}