mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-21 17:48:43 +02:00
N°8772 - Form dependencies manager implementation
- Form SDK implementation - Basic Forms - Dynamics Forms - Basic Blocks + Data Model Block - Form Compilation - Turbo integration
This commit is contained in:
36
sources/Forms/Block/Base/ChoiceFromInputsBlock.php
Normal file
36
sources/Forms/Block/Base/ChoiceFromInputsBlock.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* @copyright Copyright (C) 2010-2025 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
namespace Combodo\iTop\Forms\Block\Base;
|
||||
|
||||
use Combodo\iTop\Forms\IO\FormInput;
|
||||
use Combodo\iTop\Forms\Register\OptionsRegister;
|
||||
|
||||
/**
|
||||
* A block to manage a list of choices given by forms inputs current values.
|
||||
*
|
||||
* @package Combodo\iTop\Forms\Block\Base
|
||||
* @since 3.3.0
|
||||
*/
|
||||
class ChoiceFromInputsBlock extends ChoiceFormBlock
|
||||
{
|
||||
/** @inheritdoc */
|
||||
public function UpdateOptions(OptionsRegister $oOptionsRegister): void
|
||||
{
|
||||
parent::UpdateOptions($oOptionsRegister);
|
||||
|
||||
// Compute options based on inputs values
|
||||
$aChoices = [];
|
||||
/** @var FormInput $oInput */
|
||||
foreach ($this->GetInputs() as $oInput) {
|
||||
if ($oInput->HasValue()) {
|
||||
$aChoices[strval($oInput->GetValue())] = $oInput->GetName();
|
||||
}
|
||||
}
|
||||
$oOptionsRegister->SetOption('choices', $aChoices);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user