Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/NemidFirstName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Drupal\os2forms_nemid\Element;

use Drupal\Core\Form\FormStateInterface;

/**
* Provides a 'os2forms_nemid_first_name'.
*
* @FormElement("os2forms_nemid_first_name")
*
* @see \Drupal\Core\Render\Element\FormElement
* @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21FormElement.php/class/FormElement
* @see \Drupal\Core\Render\Element\RenderElement
* @see https://api.drupal.org/api/drupal/namespace/Drupal%21Core%21Render%21Element
* @see \Drupal\os2forms_nemid\Element\NemidFirstName
*/
class NemidFirstName extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$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;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/NemidLastName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Drupal\os2forms_nemid\Element;

use Drupal\Core\Form\FormStateInterface;

/**
* Provides a 'os2forms_nemid_last_name'.
*
* @FormElement("os2forms_nemid_last_name")
*
* @see \Drupal\Core\Render\Element\FormElement
* @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21FormElement.php/class/FormElement
* @see \Drupal\Core\Render\Element\RenderElement
* @see https://api.drupal.org/api/drupal/namespace/Drupal%21Core%21Render%21Element
* @see \Drupal\os2forms_nemid\Element\NemidLastName
*/
class NemidLastName extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$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;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/NemidMiddleName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace Drupal\os2forms_nemid\Element;

use Drupal\Core\Form\FormStateInterface;

/**
* Provides a 'os2forms_nemid_middle_name'.
*
* @FormElement("os2forms_nemid_middle_name")
*
* @see \Drupal\Core\Render\Element\FormElement
* @see https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21Element%21FormElement.php/class/FormElement
* @see \Drupal\Core\Render\Element\RenderElement
* @see https://api.drupal.org/api/drupal/namespace/Drupal%21Core%21Render%21Element
* @see \Drupal\os2forms_nemid\Element\NemidMiddleName
*/
class NemidMiddleName extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$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;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Drupal\os2forms_nemid\Plugin\WebformElement;

use Drupal\os2web_datalookup\LookupResult\CprLookupResult;

/**
* Provides a 'os2forms_nemid_first_name' element.
*
* @WebformElement(
* id = "os2forms_nemid_first_name",
* label = @Translation("NemID First name"),
* description = @Translation("Provides a NemID First name element."),
* category = @Translation("NemID"),
* )
*
* @see \Drupal\os2forms_nemid\Plugin\NemidElementBase
* @see \Drupal\os2forms_nemid\Element\NemidFirstName
*/
class NemidFirstName extends ServiceplatformenCprElementBase implements NemidElementPersonalInterface {

/**
* {@inheritdoc}
*/
public function getPrepopulateFieldFieldKey(array &$element) {
return CprLookupResult::FIRST_NAME;
}

}
29 changes: 29 additions & 0 deletions modules/os2forms_nemid/src/Plugin/WebformElement/NemidLastName.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Drupal\os2forms_nemid\Plugin\WebformElement;

use Drupal\os2web_datalookup\LookupResult\CprLookupResult;

/**
* Provides a 'os2forms_nemid_last_name' element.
*
* @WebformElement(
* id = "os2forms_nemid_last_name",
* label = @Translation("NemID Last name"),
* description = @Translation("Provides a NemID Last name element."),
* category = @Translation("NemID"),
* )
*
* @see \Drupal\os2forms_nemid\Plugin\NemidElementBase
* @see \Drupal\os2forms_nemid\Element\NemidLastName
*/
class NemidLastName extends ServiceplatformenCprElementBase implements NemidElementPersonalInterface {

/**
* {@inheritdoc}
*/
public function getPrepopulateFieldFieldKey(array &$element) {
return CprLookupResult::LAST_NAME;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Drupal\os2forms_nemid\Plugin\WebformElement;

use Drupal\os2web_datalookup\LookupResult\CprLookupResult;

/**
* Provides a 'os2forms_nemid_middle_name' element.
*
* @WebformElement(
* id = "os2forms_nemid_middle_name",
* label = @Translation("NemID Middle name"),
* description = @Translation("Provides a NemID Middle name element."),
* category = @Translation("NemID"),
* )
*
* @see \Drupal\os2forms_nemid\Plugin\NemidElementBase
* @see \Drupal\os2forms_nemid\Element\NemidMiddleName
*/
class NemidMiddleName extends ServiceplatformenCprElementBase implements NemidElementPersonalInterface {

/**
* {@inheritdoc}
*/
public function getPrepopulateFieldFieldKey(array &$element) {
return CprLookupResult::MIDDLE_NAME;
}

}
Loading