GeneralSection.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\UI\Client\EmailAccount\Sections;
  3. use ThurData\Servers\KerioEmail\App\Traits\FormExtendedTrait;
  4. use ThurData\Servers\KerioEmail\App\UI\Admin\Custom\Sections\FreeFieldsSection;
  5. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Validators\Decimal;
  6. use ThurData\Servers\KerioEmail\App\Validators\PasswordsValidator;
  7. use ThurData\Servers\KerioEmail\App\Validators\RepeatPasswordValidator;
  8. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Password;
  9. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Select;
  10. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\Text;
  11. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Sections\InputGroup;
  12. use ThurData\Servers\KerioEmail\Core\UI\Widget\Forms\Fields\InputGroupElements;
  13. /**
  14. *
  15. * Created by PhpStorm.
  16. * User: ThurData
  17. * Date: 12.11.19
  18. * Time: 13:39
  19. * Class GeneralSection
  20. */
  21. class GeneralSection extends FreeFieldsSection
  22. {
  23. protected $id = 'generalSection';
  24. protected $name = 'generalSection';
  25. use FormExtendedTrait;
  26. public function initContent()
  27. {
  28. $this->generateDoubleSection([new Text('firstname'), new Text('lastname')]);
  29. $email = new InputGroup('usernameGroup');
  30. $email->addTextField('username', false, true);
  31. $email->addInputAddon('emailSign', false, '@');
  32. $email->addInputComponent((new InputGroupElements\Text('domain'))->addHtmlAttribute('readonly','true'));
  33. $this->addSection($email);
  34. $this->generateDoubleSection([new Text('display_name'), new Select('status')]);
  35. $quota = new Text('quota');
  36. $quota->setDescription('description');
  37. $quota->addValidator(new Decimal(0));
  38. $this->generateDoubleSection([$quota, new Select('unit')]);
  39. $passwd = new Password('password');
  40. $passwd->setDescription('description');
  41. $passwd->addValidator(new PasswordsValidator());
  42. $passwd->notEmpty();
  43. $repPasswd = (new Password('repeat_password'))->addValidator(new RepeatPasswordValidator());
  44. $repPasswd->notEmpty();
  45. $this->generateDoubleSection([$passwd, $repPasswd]);
  46. }
  47. }