mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 20:48:46 +02:00
N°8772 - dynamic form
This commit is contained in:
41
sources/Forms/Block/Base/CheckboxFormBlock.php
Normal file
41
sources/Forms/Block/Base/CheckboxFormBlock.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?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\Block\AbstractFormBlock;
|
||||
use Combodo\iTop\Forms\Block\IO\Converter\StringToBooleanConverter;
|
||||
use Combodo\iTop\Forms\Block\IO\Format\BooleanIOFormat;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
|
||||
/**
|
||||
* Form block for checkbox.
|
||||
*
|
||||
*/
|
||||
class CheckboxFormBlock extends AbstractFormBlock
|
||||
{
|
||||
// outputs
|
||||
public const OUTPUT_CHECKED = 'checked';
|
||||
|
||||
/** @inheritdoc */
|
||||
public function GetFormType(): string
|
||||
{
|
||||
return CheckboxType::class;
|
||||
}
|
||||
|
||||
function InitBlockOptions(array &$aUserOptions): void
|
||||
{
|
||||
parent::InitBlockOptions($aUserOptions);
|
||||
$aUserOptions['required'] = false;
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
function InitOutputs(): void
|
||||
{
|
||||
parent::InitOutputs();
|
||||
$this->AddOutput(self::OUTPUT_CHECKED, BooleanIOFormat::class, new StringToBooleanConverter());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user