| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections;
- use ModulesGarden\ProxmoxAddon\Core\UI\Traits\Description;
- use \ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Fields\InputGroupElements;
- use \ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Validators\BaseValidator;
- /**
- * InputGroup section controler
- *
- * @author Sławomir Miśkowicz <slawomir@modulesgarden.com>
- */
- class InputGroup extends BaseSection
- {
- use Description;
- protected $id = 'inputGroup';
- protected $name = 'inputGroup';
- public function __construct($baseId = null)
- {
- parent::__construct($baseId);
- $this->description = null;
- }
- public function addInputComponent($component)
- {
- $this->addField($component);
- return $this;
- }
- public function addTextField($initName, $placecholder = false, $notEmpty = true, BaseValidator $validator = null)
- {
- $newTextField = new InputGroupElements\Text($initName);
- if ($notEmpty && !$validator)
- {
- $newTextField->notEmpty();
- }
- else
- {
- $newTextField->addValidator($validator);
- }
- if ($placecholder)
- {
- $newTextField->setPlaceholder($placecholder);
- }
- $this->addInputComponent($newTextField);
- return $this;
- }
- public function addInputAddon($initName, $title = false, $rawTitle = false)
- {
- $newAddonField = new InputGroupElements\InputAddon();
- $newAddonField->setName($initName);
- if ($title)
- {
- $newAddonField->setTitle($title);
- }
- if ($rawTitle)
- {
- $newAddonField->setRawTitle($rawTitle);
- }
- $this->addInputComponent($newAddonField);
- return $this;
- }
- }
|