mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
N°8771 - Add Symfony form component to iTop core
- IO debug
This commit is contained in:
@@ -71,7 +71,7 @@ abstract class AbstractFormBlock
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function GetOptions(): array
|
||||
public function UpdateOptions(): array
|
||||
{
|
||||
return $this->aOptions;
|
||||
}
|
||||
@@ -168,7 +168,7 @@ abstract class AbstractFormBlock
|
||||
* Attach an input to a block output.
|
||||
*
|
||||
* @param string $sInputName
|
||||
* @param FormBlock $sOutputBlock
|
||||
* @param FormBlock $oOutputBlock
|
||||
* @param string $sOutputName
|
||||
*
|
||||
* @return $this
|
||||
@@ -186,7 +186,7 @@ abstract class AbstractFormBlock
|
||||
public function HasConnections(): bool
|
||||
{
|
||||
foreach ($this->aFormInputs as $oFormInput) {
|
||||
if ($oFormInput->IsConnected()) {
|
||||
if ($oFormInput->IsBound()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ abstract class AbstractFormBlock
|
||||
|
||||
/** @var FormInput $oFormInput */
|
||||
foreach ($this->aFormInputs as $oFormInput) {
|
||||
if ($oFormInput->IsConnected()) {
|
||||
if ($oFormInput->IsBound()) {
|
||||
$aBindings[$oFormInput->GetName()] = $oFormInput->GetBinding();
|
||||
}
|
||||
}
|
||||
@@ -209,7 +209,7 @@ abstract class AbstractFormBlock
|
||||
public function IsInputsReady(string $sEventType): bool
|
||||
{
|
||||
foreach ($this->aFormInputs as $oFormInput) {
|
||||
if ($oFormInput->IsConnected()) {
|
||||
if ($oFormInput->IsBound()) {
|
||||
if(!$oFormInput->IsDataReady($sEventType)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,9 @@ class AttributeChoiceFormBlock extends ChoiceFormBlock
|
||||
}
|
||||
|
||||
/** @inheritdoc */
|
||||
public function GetOptions(): array
|
||||
public function UpdateOptions(): array
|
||||
{
|
||||
$aOptions = parent::GetOptions();
|
||||
$aOptions = parent::UpdateOptions();
|
||||
|
||||
$oBinding = $this->GetInput(self::INPUT_CLASS_NAME)->GetBinding();
|
||||
$oConnectionValue = $oBinding->oOutput->Value();
|
||||
|
||||
@@ -26,6 +26,7 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
public function InitOptions(array &$aOptions = []): array
|
||||
{
|
||||
$aOptions['multiple'] = true;
|
||||
$aOptions['required'] = false;
|
||||
$aOptions['attr'] = [
|
||||
'size' => 10,
|
||||
'style' => 'height: auto;'
|
||||
@@ -42,14 +43,18 @@ class AttributeValueChoiceFormBlock extends ChoiceFormBlock
|
||||
$this->AddInput(new FormInput(self::INPUT_ATTRIBUTE, AttributeIOFormat::class));
|
||||
}
|
||||
|
||||
public function GetOptions(): array
|
||||
public function UpdateOptions(): array
|
||||
{
|
||||
$aOptions = parent::GetOptions();
|
||||
$aOptions = parent::UpdateOptions();
|
||||
|
||||
$oBindingClassName = $this->GetInput(self::INPUT_CLASS_NAME)->GetBinding();
|
||||
if($oBindingClassName->oOutput->Value() === null || $oBindingClassName->oOutput->Value() == "")
|
||||
return $aOptions;
|
||||
$oClassName = $oBindingClassName->oOutput->Value();
|
||||
|
||||
$oBindingAttribute = $this->GetInput(self::INPUT_ATTRIBUTE)->GetBinding();
|
||||
if($oBindingAttribute->oOutput->Value() === null || $oBindingAttribute->oOutput->Value() == "")
|
||||
return $aOptions;
|
||||
$oAttribute = $oBindingAttribute->oOutput->Value();
|
||||
|
||||
$oAttDef = \MetaModel::GetAttributeDef(strval($oClassName), strval($oAttribute));
|
||||
|
||||
@@ -61,7 +61,7 @@ class FormInput extends AbstractFormIO
|
||||
return $this->oBinding->oOutput->HasValue($sEventType);
|
||||
}
|
||||
|
||||
public function IsConnected(): bool
|
||||
public function IsBound(): bool
|
||||
{
|
||||
return $this->oBinding !== null;
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
|
||||
namespace Combodo\iTop\Forms\FormBuilder;
|
||||
|
||||
use Combodo\iTop\Forms\Block\FormBlock;
|
||||
use Combodo\iTop\Forms\Block\IO\FormInput;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
|
||||
@@ -102,7 +100,7 @@ class DependencyHandler
|
||||
if(!$oDependentBlock->IsAdded() && $oDependentBlock->IsInputsReady($sEventType)) {
|
||||
|
||||
// Get the dependent field options
|
||||
$aOptions = $oDependentBlock->GetOptions();
|
||||
$aOptions = $oDependentBlock->UpdateOptions();
|
||||
|
||||
// Add the listener callback to the dependent field if it is also a dependency for another field
|
||||
if($this->aDependenciesMap->IsTheBlockInDependencies($oDependentBlock->getName())) {
|
||||
|
||||
@@ -57,7 +57,7 @@ class FormBuilder implements FormBuilderInterface, \IteratorAggregate
|
||||
$this->builder->add($oSubFormBlock->GetName(), HiddenType::class);
|
||||
$aDependentBlocks[] = $oSubFormBlock;
|
||||
} else {
|
||||
$this->add($oSubFormBlock->GetName(), $oSubFormBlock->GetFormType(), $oSubFormBlock->getOptions());
|
||||
$this->add($oSubFormBlock->GetName(), $oSubFormBlock->GetFormType(), $oSubFormBlock->UpdateOptions());
|
||||
$oSubFormBlock->SetAdded(true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user