CreateForm.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. /* * ********************************************************************
  3. * ProxmoxVPS Product developed. (27.03.19)
  4. * *
  5. *
  6. * CREATED BY MODULESGARDEN -> http://modulesgarden.com
  7. * CONTACT -> contact@modulesgarden.com
  8. *
  9. *
  10. * This software is furnished under a license and may be used and copied
  11. * only in accordance with the terms of such license and with the
  12. * inclusion of the above copyright notice. This software or any other
  13. * copies thereof may not be provided or otherwise made available to any
  14. * other person. No title to and ownership of the software is hereby
  15. * transferred.
  16. *
  17. *
  18. * ******************************************************************** */
  19. namespace ModulesGarden\Servers\ProxmoxVps\App\UI\IpAddress\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\UI\Validators\MacAddressValidator;
  21. use ModulesGarden\Servers\ProxmoxVps\App\UI\IpAddress\Providers\DiskProvider;
  22. use ModulesGarden\Servers\ProxmoxVps\App\UI\IpAddress\Providers\IpAddressProvider;
  23. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\CidrValidator;
  24. use ModulesGarden\Servers\ProxmoxVps\App\UI\Validators\IpAddressValidator;
  25. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Interfaces\AdminArea;
  26. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\BaseForm;
  27. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Switcher;
  28. use ModulesGarden\Servers\ProxmoxVps\Core\UI\Widget\Forms\Fields\Text;
  29. class CreateForm extends BaseForm implements AdminArea
  30. {
  31. public function initContent()
  32. {
  33. $this->initIds('createForm');
  34. $this->setFormType('create');
  35. $this->setProvider(new IpAddressProvider());
  36. $this->initFields();
  37. $this->loadDataToForm();
  38. }
  39. public function getAllowedActions()
  40. {
  41. return ['create'];
  42. }
  43. private function initFields()
  44. {
  45. //ip
  46. $field = new Text('ip');
  47. $field->addValidator(new IpAddressValidator(true));
  48. $this->addField($field);
  49. // mac_address
  50. $field = new Text('mac_address');
  51. $field->addValidator(new MacAddressValidator());
  52. $this->addField($field);
  53. //subnet_mask
  54. $field = new Text('subnet_mask');
  55. $field->addValidator(new IpAddressValidator(false));
  56. $this->addField($field);
  57. //gateway
  58. $field = new Text('gateway');
  59. $field->addValidator(new IpAddressValidator(false));
  60. $this->addField($field);
  61. $field = new Text('cidr');
  62. $field->addValidator(new CidrValidator(true));
  63. $field->setPlaceholder('24');
  64. $this->addField($field);
  65. //network
  66. $field = new Switcher('network');
  67. $field->setDescription('description');
  68. $this->addField($field);
  69. }
  70. }