CreateForm.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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\ProxmoxCloudVps\App\UI\VirtualNetwork\Forms;
  20. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\CidrValidator;
  21. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\VirtualIpAddressValidator;
  22. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VirtualNetwork\Providers\VirtualNetworkProvider;
  23. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\ClientArea;
  24. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\BaseForm;
  25. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  26. class CreateForm extends BaseForm implements ClientArea
  27. {
  28. public function initContent()
  29. {
  30. $this->initIds('createForm');
  31. $this->setFormType('create');
  32. $this->setProvider(new VirtualNetworkProvider());
  33. $this->initFields();
  34. $this->loadDataToForm();
  35. }
  36. public function getAllowedActions()
  37. {
  38. return ['create'];
  39. }
  40. private function initFields()
  41. {
  42. //name
  43. $field = new Text('name');
  44. $field->notEmpty();
  45. $this->addField($field);
  46. //pool
  47. $field = new Text('pool');
  48. $field->addValidator(new VirtualIpAddressValidator(true, false));
  49. $field->setPlaceholder('192.168.0.100');
  50. $this->addField($field);
  51. //cidr
  52. $field = new Text('cidr');
  53. $field->setPlaceholder('24');
  54. $field->addValidator(new CidrValidator(true));
  55. $this->addField($field);
  56. //gateway
  57. $field = new Text('gateway');
  58. $field->setPlaceholder('192.168.0.1');
  59. $field->addValidator(new VirtualIpAddressValidator(false, false));
  60. $this->addField($field);
  61. }
  62. }