Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

S2FRMS-40/S2FRMS-58 child select #111

Merged
merged 17 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all 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]

- [S2FRMS-40] Adding child select autopopulate fields

## [3.15.4] 2024-07-08

- [#117](https://github.com/OS2Forms/os2forms/pull/117)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,14 @@ private function getRecipientElements(): array {
'os2forms_nemid_company_cvr_fetch_data',
'os2forms_nemid_cpr',
'os2forms_person_lookup',
'os2forms_mitid_child_other_guardian',
// @todo Remove these when we remove the elements.
'cpr_element',
'cpr_value_element',
'cvr_element',
'cvr_value_element',
];

$elements = array_filter(
$elements,
static function (array $element) use ($elementTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ private function getRecipientElementOptions(): array {
'cvr_element',
'cvr_value_element',
'os2forms_person_lookup',
'os2forms_mitid_child_other_guardian',
];

$isAllowedElement = static fn ($e) => in_array($e['#type'], $elementTypes, TRUE);
Expand Down
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/MitidChildAddress.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_mitid_child_address'.
*
* @FormElement("os2forms_mitid_child_address")
*
* @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\NemidName
*/
class MitidChildAddress extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$class, 'processMitidChildAddress'],
[$class, 'processAjaxForm'],
],
'#element_validate' => [
[$class, 'validateMitidChildAddress'],
],
'#pre_render' => [
[$class, 'preRenderMitidChildAddress'],
],
'#theme' => 'input__os2forms_mitid_child_address',
];
}

/**
* Processes a 'os2forms_mitid_child_address' element.
*/
public static function processMitidChildAddress(&$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 'os2forms_mitid_child_address'.
*/
public static function validateMitidChildAddress(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add custom validation logic.
}

/**
* {@inheritdoc}
*/
public static function preRenderMitidChildAddress(array $element) {
$element = parent::prerenderNemidElementBase($element);
static::setAttributes($element, ['form-text', 'os2forms-mitid-child-address']);
return $element;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/MitidChildApartmentNr.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_mitid_child_apartment_nr'.
*
* @FormElement("os2forms_mitid_child_apartment_nr")
*
* @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\NemidApartmentNr
*/
class MitidChildApartmentNr extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$class, 'processMitidChildApartmentNr'],
[$class, 'processAjaxForm'],
],
'#element_validate' => [
[$class, 'validateMitidChildApartmentNr'],
],
'#pre_render' => [
[$class, 'preRenderMitidChildApartmentNr'],
],
'#theme' => 'input__os2forms_mitid_child_apartmentNr',
];
}

/**
* Processes a 'os2forms_mitid_child_apartmentNr' element.
*/
public static function processMitidChildApartmentNr(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add and manipulate your element's properties and callbacks.
return $element;
}

/**
* Webform element validation handler 'os2forms_mitid_child_apartmentNr'.
*/
public static function validateMitidChildApartmentNr(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add custom validation logic.
}

/**
* {@inheritdoc}
*/
public static function preRenderMitidChildApartmentNr(array $element) {
$element = parent::prerenderNemidElementBase($element);
static::setAttributes($element, ['form-text', 'os2forms-mitid-child-apartment-nr']);
return $element;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/MitidChildCity.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_mitid_child_city'.
*
* @FormElement("os2forms_mitid_child_city")
*
* @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\NemidCity
*/
class MitidChildCity extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$class, 'processMitidChildCity'],
[$class, 'processAjaxForm'],
],
'#element_validate' => [
[$class, 'validateMitidChildCity'],
],
'#pre_render' => [
[$class, 'preRenderMitidChildCity'],
],
'#theme' => 'input__os2forms_mitid_child_city',
];
}

/**
* Processes a 'os2forms_mitid_child_city' element.
*/
public static function processMitidChildCity(&$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_mitid_child_city'.
*/
public static function validateMitidChildCity(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add custom validation logic.
}

/**
* {@inheritdoc}
*/
public static function preRenderMitidChildCity(array $element) {
$element = parent::prerenderNemidElementBase($element);
static::setAttributes($element, ['form-text', 'os2forms-mitid-child-city']);
return $element;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/MitidChildCoaddress.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_mitid_child_coaddress'.
*
* @FormElement("os2forms_mitid_child_coaddress")
*
* @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\NemidCoaddress
*/
class MitidChildCoaddress extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$class, 'processMitidChildCoaddress'],
[$class, 'processAjaxForm'],
],
'#element_validate' => [
[$class, 'validateMitidChildCoaddress'],
],
'#pre_render' => [
[$class, 'preRenderMitidChildCoaddress'],
],
'#theme' => 'input__os2forms_mitid_child_coaddress',
];
}

/**
* Processes a 'os2forms_mitid_child_coaddress' element.
*/
public static function processMitidChildCoaddress(&$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 'os2forms_mitid_child_coaddress'.
*/
public static function validateMitidChildCoaddress(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add custom validation logic.
}

/**
* {@inheritdoc}
*/
public static function preRenderMitidChildCoaddress(array $element) {
$element = parent::prerenderNemidElementBase($element);
static::setAttributes($element, ['form-text', 'os2forms-mitid-child-coaddress']);
return $element;
}

}
64 changes: 64 additions & 0 deletions modules/os2forms_nemid/src/Element/MitidChildCpr.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_mitid_child_cpr'.
*
* @FormElement("os2forms_mitid_child_cpr")
*
* @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\NemidCpr
*/
class MitidChildCpr extends NemidElementBase {

/**
* {@inheritdoc}
*/
public function getInfo() {
$class = get_class($this);
return parent::getInfo() + [
'#process' => [
[$class, 'processMitidChildCpr'],
[$class, 'processAjaxForm'],
],
'#element_validate' => [
[$class, 'validateMitidChildCpr'],
],
'#pre_render' => [
[$class, 'preRenderMitidChildCpr'],
],
'#theme' => 'input__os2forms_mitid_child_cpr',
];
}

/**
* Processes a 'os2forms_mitid_child_cpr' element.
*/
public static function processMitidChildCpr(&$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_mitid_child_cpr'.
*/
public static function validateMitidChildCpr(&$element, FormStateInterface $form_state, &$complete_form) {
// Here you can add custom validation logic.
}

/**
* {@inheritdoc}
*/
public static function preRenderMitidChildCpr(array $element) {
$element = parent::prerenderNemidElementBase($element);
static::setAttributes($element, ['form-text', 'os2forms-mitid-child-cpr']);
return $element;
}

}
Loading
Loading