View source
<?php
function webform_bt_layout_help($section = 'admin/help#webform_bt_layout', $arg = NULL) {
switch ($section) {
case 'admin/help#webform_bt_layout':
return nl2br(file_get_contents(drupal_get_path('module', 'webform_bt_layout') . '/README.txt'));
}
return '';
}
function webform_bt_layout_webform_component_info() {
return array(
'bt_layout_row' => array(
'label' => t('Bootstrap layout row'),
'description' => t('Create bootstrap row.'),
'features' => array(
'csv' => FALSE,
'required' => FALSE,
'conditional' => FALSE,
'group' => TRUE,
'title_display' => FALSE,
'title_inline' => FALSE,
'description' => FALSE,
'wrapper_classes' => FALSE,
),
'file' => 'bt_layout_row.inc',
),
'bt_layout_cols' => array(
'label' => t('Bootstrap layout cols'),
'description' => t('Allows you to arrange fields into columns.'),
'features' => array(
'csv' => FALSE,
'required' => FALSE,
'conditional' => FALSE,
'group' => TRUE,
'title_display' => FALSE,
'title_inline' => FALSE,
'description' => FALSE,
'wrapper_classes' => FALSE,
),
'file' => 'bt_layout_cols.inc',
),
);
}
function webform_bt_layout_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == 'webform_components_form') {
$form['add']['add']['#submit'][] = 'webform_bt_layout_form_add_submit';
}
}
function webform_bt_layout_webform_component_presave(&$component) {
if ($component['type'] === 'bt_layout_cols' || $component['type'] === 'bt_layout_row') {
$component['name'] = $component['form_key'];
}
}
function webform_bt_layout_form_add_submit($form, &$form_state) {
$component = $form_state['values']['add'];
if ($component['type'] === 'bt_layout_cols' || $component['type'] === 'bt_layout_row') {
$nid = $component['nid'] = $form_state['values']['nid'];
$component['form_key'] = _webform_safe_name($component['name']);
unset($component['required'], $component['cid'], $component['add']);
webform_component_defaults($component);
$cid = webform_component_insert($component);
$form_state['redirect'] = array(
"node/{$nid}/webform/components/{$cid}",
);
}
}