public static function WebformTestElementProperties::submitAjaxElementCallback in Webform 6.x
Same name and namespace in other branches
- 8.5 tests/modules/webform_test_element/src/Plugin/WebformElement/WebformTestElementProperties.php \Drupal\webform_test_element\Plugin\WebformElement\WebformTestElementProperties::submitAjaxElementCallback()
Ajax element submit callback.
Parameters
array $form: An associative array containing the structure of the form.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Overrides WebformAjaxElementTrait::submitAjaxElementCallback
File
- tests/
modules/ webform_test_element/ src/ Plugin/ WebformElement/ WebformTestElementProperties.php, line 97
Class
- WebformTestElementProperties
- Provides a 'webform_test_element_properties' element.
Namespace
Drupal\webform_test_element\Plugin\WebformElementCode
public static function submitAjaxElementCallback(array $form, FormStateInterface $form_state) {
// Get the webform test container by going up one level.
$button = $form_state
->getTriggeringElement();
$element =& NestedArray::getValue($form, array_slice($button['#array_parents'], 0, -1));
// Update timestamp on 'property_b'.
NestedArray::setValue($form_state
->getUserInput(), $element['property_b']['#parents'], $element['property_a']['#value']);
$form_state
->setValueForElement($element['property_b'], $element['property_a']['#value']);
// Update timestamp on 'property_c'.
$property_c = date('c');
NestedArray::setValue($form_state
->getUserInput(), $element['property_c']['#parents'], $property_c);
$form_state
->setValueForElement($element['property_c'], $property_c);
// Rebuild the form.
$form_state
->setRebuild();
}