InputGroup.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections;
  3. use ThurData\Servers\KerioEmail\Core\UI\Traits\Description;
  4. use \ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  5. use \ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Validators\BaseValidator;
  6. /**
  7. * InputGroup section controler
  8. *
  9. * @autor ThurData <info@thurdata.ch>
  10. */
  11. class InputGroup extends BaseSection
  12. {
  13. use Description;
  14. protected $id = 'inputGroup';
  15. protected $name = 'inputGroup';
  16. public function __construct($baseId = null)
  17. {
  18. parent::__construct($baseId);
  19. $this->description = null;
  20. }
  21. public function addInputComponent($component)
  22. {
  23. $this->addField($component);
  24. return $this;
  25. }
  26. public function addTextField($initName, $placecholder = false, $notEmpty = true, BaseValidator $validator = null)
  27. {
  28. $newTextField = new InputGroupElements\Text($initName);
  29. if ($notEmpty && !$validator)
  30. {
  31. $newTextField->notEmpty();
  32. }else{
  33. $newTextField->addValidator($validator);
  34. }
  35. if ($placecholder)
  36. {
  37. $newTextField->setPlaceholder($placecholder);
  38. }
  39. $this->addInputComponent($newTextField);
  40. return $this;
  41. }
  42. public function addInputAddon($initName, $title = false, $rawTitle = false)
  43. {
  44. $newAddonField = new InputGroupElements\InputAddon();
  45. $newAddonField ->setName($initName);
  46. if ($title)
  47. {
  48. $newAddonField->setTitle($title);
  49. }
  50. if ($rawTitle)
  51. {
  52. $newAddonField->setRawTitle($rawTitle);
  53. }
  54. $this->addInputComponent($newAddonField);
  55. return $this;
  56. }
  57. }