Revision 76bdcd04
Added by Assos Assos almost 6 years ago
drupal7/sites/all/modules/webform/includes/webform.conditionals.inc | ||
---|---|---|
34 | 34 |
// Drop PHP reference. |
35 | 35 |
unset($conditional); |
36 | 36 |
|
37 |
// Check the current topological sort order for the conditionals and report any errors,
|
|
38 |
// but only for actual form submissions and not for ajax-related form builds, such as
|
|
39 |
// adding or removing a condition or conditional group. |
|
37 |
// Check the current topological sort order for the conditionals and report |
|
38 |
// any errors, but only for actual form submissions and not for ajax-related
|
|
39 |
// form builds, such as adding or removing a condition or conditional group.
|
|
40 | 40 |
if (empty($form_state['triggering_element']['#ajax'])) { |
41 | 41 |
$node->webform['conditionals'] = $conditionals; |
42 | 42 |
webform_get_conditional_sorter($node)->reportErrors($conditionals); |
... | ... | |
143 | 143 |
'#submit' => array('webform_conditionals_form_submit'), |
144 | 144 |
); |
145 | 145 |
|
146 |
// Estimate if the form is too long for PHP max_input_vars and detect whether a previous submission was truncated. |
|
147 |
// The estimate will be accurate because the form elements for this page are well known. Ajax use of this |
|
148 |
// page will not generate user-visible errors, so a preflight may be the only indication to the user that |
|
149 |
// the page is too long. |
|
146 |
// Estimate if the form is too long for PHP max_input_vars and detect whether |
|
147 |
// a previous submission was truncated. The estimate will be accurate because |
|
148 |
// the form elements for this page are well known. Ajax use of this page will |
|
149 |
// not generate user-visible errors, so a preflight may be the only indication |
|
150 |
// to the user that the page is too long. |
|
150 | 151 |
webform_input_vars_check($form, $form_state, 'conditionals', ''); |
151 | 152 |
return $form; |
152 | 153 |
} |
... | ... | |
221 | 222 |
$component_type = $node->webform['components'][$action['target']['#value']]['type']; |
222 | 223 |
if (!webform_conditional_action_able($component_type, $action['action']['#value'])) { |
223 | 224 |
form_set_error('conditionals][' . $conditional_key . '][actions][' . $action_key . '][action', |
224 |
t('A component of type %type can\'t be %action. (%target)',
|
|
225 |
t("A component of type %type can't be %action. (%target)",
|
|
225 | 226 |
array( |
226 | 227 |
'%action' => $action['action']['#options'][$action['action']['#value']], |
227 | 228 |
'%type' => $component_options[$component_type], |
... | ... | |
341 | 342 |
* Form API #process function to expand a webform conditional element. |
342 | 343 |
*/ |
343 | 344 |
function _webform_conditional_expand($element) { |
345 |
$default_operator = 'and'; |
|
346 |
|
|
344 | 347 |
$element['#tree'] = TRUE; |
345 | 348 |
$element['#default_value'] += array( |
346 |
'andor' => 'and',
|
|
349 |
'andor' => $default_operator,
|
|
347 | 350 |
); |
348 | 351 |
|
349 | 352 |
$wrapper_id = drupal_clean_css_identifier(implode('-', $element['#parents'])) . '-ajax'; |
... | ... | |
381 | 384 |
'remove' => _webform_conditional_remove_expand($element, $rid), |
382 | 385 |
); |
383 | 386 |
$andor_stack[++$level] = array( |
384 |
'value' => $conditional['operator'],
|
|
387 |
'value' => isset($conditional['operator']) ? $conditional['operator'] : $default_operator,
|
|
385 | 388 |
'parents' => array_merge($element['#parents'], array('rules', $rid, 'operator')), |
386 | 389 |
'rid' => $rid, |
387 | 390 |
'first' => TRUE, |
... | ... | |
463 | 466 |
'#value' => $subconditional ? t('(+)') : t('+'), |
464 | 467 |
'#submit' => array('webform_conditional_element_add'), |
465 | 468 |
'#subconditional' => $subconditional, |
466 |
'#name' => implode('_', $element['#parents']) . '_rules_' . $rid . |
|
467 |
($subconditional ? '_add_subconditional' : '_add'), |
|
469 |
'#name' => implode('_', $element['#parents']) . '_rules_' . $rid . ($subconditional ? '_add_subconditional' : '_add'), |
|
468 | 470 |
'#attributes' => array('class' => array('webform-conditional-rule-add')), |
469 | 471 |
'#ajax' => array( |
470 | 472 |
'progress' => 'none', |
... | ... | |
546 | 548 |
), |
547 | 549 |
'invert' => array( |
548 | 550 |
'#type' => 'select', |
549 |
'#title' => t('Is/Isn\'t'),
|
|
551 |
'#title' => t("Is/Isn't"),
|
|
550 | 552 |
'#options' => array( |
551 | 553 |
'0' => t('is'), |
552 |
'1' => t('isn\'t'),
|
|
554 |
'1' => t("isn't"),
|
|
553 | 555 |
), |
554 | 556 |
'#default_value' => $action['invert'], |
555 | 557 |
), |
... | ... | |
618 | 620 |
* ); |
619 | 621 |
* @endcode |
620 | 622 |
* - forms[$form_key]: A string representing an HTML form for an operator. |
621 |
* - forms[$form_key][$source]: Or instead of a single form for all components,
|
|
622 |
* if each component requires its own form, key each component by its source
|
|
623 |
* value (currently always the component ID). |
|
623 |
* - forms[$form_key][$source]: Or instead of a single form for all |
|
624 |
* components, if each component requires its own form, key each component
|
|
625 |
* by its source value (currently always the component ID).
|
|
624 | 626 |
* |
625 |
* @param $node |
|
627 |
* @param object $node
|
|
626 | 628 |
* The Webform node for which these forms are being generated. |
627 | 629 |
*/ |
628 | 630 |
function _webform_conditional_expand_value_forms($node) { |
... | ... | |
1439 | 1441 |
$source_parents = webform_component_parent_keys($node, $source_component); |
1440 | 1442 |
$source_id = 'webform-component--' . str_replace('_', '-', implode('--', $source_parents)); |
1441 | 1443 |
|
1442 |
// If this source has a value set, add that as a setting. |
|
1443 |
// NULL or array(NULL) should be sent as an empty array to simplify the jQuery. |
|
1444 |
// If this source has a value set, add that as a setting. NULL or |
|
1445 |
// array(NULL) should be sent as an empty array to simplify the |
|
1446 |
// jQuery. |
|
1444 | 1447 |
if (isset($submission_data[$source_component['cid']])) { |
1445 | 1448 |
$source_value = $submission_data[$source_component['cid']]; |
1446 | 1449 |
$source_value = is_array($source_value) ? $source_value : array($source_value); |
Also available in: Unified diff
Weekly update of contrib modules