UpdateForm.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /* * ********************************************************************
  3. * Wordpress_Manager Product developed. (Dec 11, 2017)
  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\ProxmoxAddon\App\UI\Cluster\Forms;
  20. use ModulesGarden\ProxmoxAddon\App\UI\Cluster\Providers\NodeSettingProvider;
  21. use ModulesGarden\ProxmoxAddon\App\UI\Validators\NumberValidator;
  22. use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
  23. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\BaseForm;
  24. use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Fields;
  25. /**
  26. * Description of CreateForm
  27. *
  28. * @author Pawel Kopec <pawelk@modulesgarden.com>
  29. */
  30. class UpdateForm extends BaseForm implements AdminArea
  31. {
  32. public function initContent()
  33. {
  34. $this->initIds('nodeUpdateForm');
  35. $this->setFormType('update');
  36. $this->setProvider(new NodeSettingProvider);
  37. $this->initFields();
  38. $this->loadDataToForm();
  39. }
  40. protected function initFields()
  41. {
  42. //Server ID
  43. $this->addField(new Fields\Hidden('server_id'));
  44. //Node
  45. $this->addField(new Fields\Hidden('node'));
  46. //VM create
  47. $field = (new Fields\Switcher('vmCreate'))->setDefaultValue('on')->setDescription('description');
  48. $this->addField($field);
  49. //VMs max
  50. $field = ((new Fields\Text('vmsMax'))->addValidator(new NumberValidator(1, null))->setDescription('description'));
  51. $this->addField($field);
  52. //CPU max
  53. $field = ((new Fields\Text('cpuMax'))->addValidator(new NumberValidator(1, null))->setDescription('description'));
  54. $this->addField($field);
  55. //Disk max
  56. $field = ((new Fields\Text('diskMax'))->addValidator(new NumberValidator(1, null))->setDescription('description'));
  57. $this->addField($field);
  58. //RAM max
  59. $field = ((new Fields\Text('ramMax'))->addValidator(new NumberValidator(1, null))->setDescription('description'));
  60. $this->addField($field);
  61. //Default Storage
  62. $field = ((new Fields\Select('defaultStorage'))->setDescription('description'));
  63. $this->addField($field);
  64. }
  65. protected function getDefaultActions()
  66. {
  67. return ['update'];
  68. }
  69. }