N°3537 run_query : use Field instead of InputWithLabel

This commit is contained in:
Pierre Goiffon
2020-12-16 15:57:23 +01:00
parent 2b0691daa6
commit 85e9073228
7 changed files with 60 additions and 49 deletions

View File

@@ -8,6 +8,7 @@
namespace Combodo\iTop\Application\UI\Base\Component\Input;
use Combodo\iTop\Application\UI\Base\Component\Field\Field;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\Select;
use Combodo\iTop\Application\UI\Base\Component\Input\Select\SelectOption;
@@ -25,6 +26,15 @@ class InputFactory
return $oInput;
}
/**
* If you need to have a real field with a label, you might use a {@link Field} component instead
*
* @param string $sName
* @param string $sLabel
* @param string|null $sId
*
* @return \Combodo\iTop\Application\UI\Base\Component\Input\InputWithLabel
*/
public static function MakeForSelectWithLabel(string $sName, string $sLabel, ?string $sId = null): InputWithLabel
{
$oInput = new Select($sId);
@@ -38,22 +48,6 @@ class InputFactory
return $oInputWithLabel;
}
public static function MakeForTextareaWithLabel(
string $sName, string $sLabel, ?string $sId = null, ?string $sValue = null,
?int $iCols = null, ?int $iRows = null
): InputWithLabel
{
$oTextArea = new TextArea($sValue, $sId, $iCols, $iRows);
$oTextArea->SetName($sName);
if (is_null($sId)) {
$sId = $oTextArea->GetId();
}
$oInputWithLabel = new InputWithLabel($sLabel, $oTextArea, $sId);
return $oInputWithLabel;
}
public static function MakeForSelect(string $sName, ?string $sId = null): Select
{
$oInput = new Select($sId);

View File

@@ -10,36 +10,46 @@ namespace Combodo\iTop\Application\UI\Base\Component\Input;
use Combodo\iTop\Application\UI\Base\UIBlock;
/**
* You might want to use a {@link \Combodo\iTop\Application\UI\Base\Component\Field\Field} component instead...
*
* @package Combodo\iTop\Application\UI\Base\Component\Input
*/
class InputWithLabel extends UIBlock
{
public const DEFAULT_HTML_TEMPLATE_REL_PATH = 'base/components/input/inputwithlabel';
/** @var string */
protected $sLabel;
/** @var \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput */
/** @var \Combodo\iTop\Application\UI\Base\Component\Input\Input */
protected $oInput;
/** @var bool */
protected $bHasBr;
public function __construct(string $sLabel, AbstractInput $oInput, ?string $sId, ?bool $bHasBr = null)
/**
* @param string $sLabel
* @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput
* @param string|null $sId
*/
public function __construct(string $sLabel, AbstractInput $oInput, ?string $sId)
{
parent::__construct($sId);
$this->sLabel = $sLabel;
$this->oInput = $oInput;
if (is_null($bHasBr)) {
$this->bHasBr = ($oInput instanceof TextArea);
} else {
$this->bHasBr = $bHasBr;
}
}
public function GetInput(): AbstractInput
/**
* @return \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput
*/
public function GetInput()
{
return $this->oInput;
}
public function SetInput(AbstractInput $oInput): InputWithLabel
/**
* @param \Combodo\iTop\Application\UI\Base\Component\Input\AbstractInput $oInput
*
* @return $this
*/
public function SetInput(AbstractInput $oInput)
{
$this->oInput = $oInput;
@@ -63,12 +73,6 @@ class InputWithLabel extends UIBlock
public function SetLabel(string $sLabel): InputWithLabel
{
$this->sLabel = $sLabel;
return $this;
}
public function HasBr(): bool
{
return $this->bHasBr;
}
}