Commit 9af4fd50 authored by jrockowitz's avatar jrockowitz

Issue #3076750: Add Webform Options Limit Handler. Add validation.

parent ca406cb8
......@@ -2,7 +2,7 @@ webform.handler.options_limit:
type: mapping
label: Example
mapping:
element:
element_key:
type: string
label: 'Element'
limits:
......
......@@ -5,7 +5,7 @@
*
* Available variables:
* - settings: The current configuration for this handler:
* - element: The options element.
* - element_key: The options element.
* - debug: Debugging flag.
* - handler: The handler information, including:
* - id: The handler plugin id.
......
......@@ -201,7 +201,7 @@ handlers:
conditions: { }
weight: 0
settings:
element: options_limit_default
element_key: options_limit_default
limits:
A: 1
B: 2
......@@ -212,7 +212,7 @@ handlers:
option_single_message: '[@remaining remaining]'
option_none_message: '[@remaining remaining]'
option_unlimited_message: '[Unlimited]'
option_error_message: '@label is unavailable'
option_error_message: '@name: @label is unavailable.'
debug: false
options_limit_messages:
id: options_limit
......@@ -222,7 +222,7 @@ handlers:
conditions: { }
weight: 0
settings:
element: options_limit_messages
element_key: options_limit_messages
limits:
D: 1
E: 2
......@@ -233,5 +233,5 @@ handlers:
option_single_message: '@remaining option remaining / @limit limit / @total total'
option_none_message: 'No options remaining / @limit limit / @total total'
option_unlimited_message: 'Unlimited / @total total'
option_error_message: '@label is unavailable'
option_error_message: '@name: @label is unavailable.'
debug: false
......@@ -220,7 +220,7 @@ handlers:
conditions: { }
weight: 0
settings:
element: select
element_key: select
limits:
A: 1
B: 2
......
......@@ -426,6 +426,13 @@ class WebformSubmission extends ContentEntityBase implements WebformSubmissionIn
return $this;
}
/**
* {@inheritdoc}
*/
public function getElementOriginalData($key) {
return (isset($this->originalData[$key])) ? $this->originalData[$key] : NULL;
}
/**
* {@inheritdoc}
*/
......
......@@ -181,7 +181,7 @@ class WebformElementManager extends DefaultPluginManager implements FallbackPlug
$this->moduleHandler->alter($hooks, $element, $form_state, $context);
// Allow handlers to alter the webform element.
if ($webform) {
if ($webform_submission) {
$webform->invokeHandlers('alterElement', $element, $form_state, $context);
}
}
......
......@@ -338,6 +338,18 @@ interface WebformSubmissionInterface extends ContentEntityInterface, EntityOwner
*/
public function setOriginalData(array $data);
/**
* Get a webform submission element's original data.
*
* @param string $key
* An webform submission element's key.
*
* @return mixed
* An webform submission element's original data/value.
*/
public function getElementOriginalData($key);
/**
* Gets the webform submission's token.
*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment