View source
<?php
module_load_include('inc', 'webform_matrix_component', '/components/matrix');
module_load_include('inc', 'webform', '/includes/webform.components');
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, $formid) {
if ($form['type']['#value'] == 'matrix') {
$component = $form_state['build_info']['args'][1];
$matrix_form = _webform_matrix_component_get_column_form($form, $form_state, $component);
$form = array_merge($form, $matrix_form);
}
}
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,
);
}