diff --git a/CHANGELOG.md b/CHANGELOG.md index ff239913..da4b1baf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ before starting to add changes. Use example [placed in the end of the page](#exa ## [Unreleased] +- [PR-325](https://github.com/OS2Forms/os2forms/pull/325) + Added NemID first name, middle name and last name webform elements. - [PR-322](https://github.com/OS2Forms/os2forms/pull/322) Update Digital Post handler error messages. - [PR-320](https://github.com/OS2Forms/os2forms/pull/320) diff --git a/modules/os2forms_nemid/src/Element/NemidFirstName.php b/modules/os2forms_nemid/src/Element/NemidFirstName.php new file mode 100644 index 00000000..22be1147 --- /dev/null +++ b/modules/os2forms_nemid/src/Element/NemidFirstName.php @@ -0,0 +1,64 @@ + [ + [$class, 'processNemidFirstName'], + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateNemidFirstName'], + ], + '#pre_render' => [ + [$class, 'preRenderNemidFirstName'], + ], + '#theme' => 'input__os2forms_nemid_first_name', + ]; + } + + /** + * Processes a 'os2forms_nemid_first_name' element. + */ + public static function processNemidFirstName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add and manipulate your element's properties and callbacks. + return $element; + } + + /** + * Webform element validation handler for #type 'os2forms_nemid_first_name'. + */ + public static function validateNemidFirstName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add custom validation logic. + } + + /** + * {@inheritdoc} + */ + public static function preRenderNemidFirstName(array $element) { + $element = parent::prerenderNemidElementBase($element); + static::setAttributes($element, ['form-text', 'os2forms-nemid-first-name']); + return $element; + } + +} diff --git a/modules/os2forms_nemid/src/Element/NemidLastName.php b/modules/os2forms_nemid/src/Element/NemidLastName.php new file mode 100644 index 00000000..251b1144 --- /dev/null +++ b/modules/os2forms_nemid/src/Element/NemidLastName.php @@ -0,0 +1,64 @@ + [ + [$class, 'processNemidLastName'], + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateNemidLastName'], + ], + '#pre_render' => [ + [$class, 'preRenderNemidLastName'], + ], + '#theme' => 'input__os2forms_nemid_last_name', + ]; + } + + /** + * Processes a 'os2forms_nemid_last_name' element. + */ + public static function processNemidLastName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add and manipulate your element's properties and callbacks. + return $element; + } + + /** + * Webform element validation handler for #type 'os2forms_nemid_last_name'. + */ + public static function validateNemidLastName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add custom validation logic. + } + + /** + * {@inheritdoc} + */ + public static function preRenderNemidLastName(array $element) { + $element = parent::prerenderNemidElementBase($element); + static::setAttributes($element, ['form-text', 'os2forms-nemid-last-name']); + return $element; + } + +} diff --git a/modules/os2forms_nemid/src/Element/NemidMiddleName.php b/modules/os2forms_nemid/src/Element/NemidMiddleName.php new file mode 100644 index 00000000..48c038ec --- /dev/null +++ b/modules/os2forms_nemid/src/Element/NemidMiddleName.php @@ -0,0 +1,64 @@ + [ + [$class, 'processNemidMiddleName'], + [$class, 'processAjaxForm'], + ], + '#element_validate' => [ + [$class, 'validateNemidMiddleName'], + ], + '#pre_render' => [ + [$class, 'preRenderNemidMiddleName'], + ], + '#theme' => 'input__os2forms_nemid_middle_name', + ]; + } + + /** + * Processes a 'os2forms_nemid_middle_name' element. + */ + public static function processNemidMiddleName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add and manipulate your element's properties and callbacks. + return $element; + } + + /** + * Webform element validation handler for #type 'os2forms_nemid_middle_name'. + */ + public static function validateNemidMiddleName(&$element, FormStateInterface $form_state, &$complete_form) { + // Here you can add custom validation logic. + } + + /** + * {@inheritdoc} + */ + public static function preRenderNemidMiddleName(array $element) { + $element = parent::prerenderNemidElementBase($element); + static::setAttributes($element, ['form-text', 'os2forms-nemid-middle-name']); + return $element; + } + +} diff --git a/modules/os2forms_nemid/src/Plugin/WebformElement/NemidFirstName.php b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidFirstName.php new file mode 100644 index 00000000..1f0b2468 --- /dev/null +++ b/modules/os2forms_nemid/src/Plugin/WebformElement/NemidFirstName.php @@ -0,0 +1,29 @@ +