| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- <?php
- /* * ********************************************************************
- * Wordpress_Manager Product developed. (Dec 11, 2017)
- * *
- *
- * CREATED BY MODULESGARDEN -> http://modulesgarden.com
- * CONTACT -> contact@modulesgarden.com
- *
- *
- * This software is furnished under a license and may be used and copied
- * only in accordance with the terms of such license and with the
- * inclusion of the above copyright notice. This software or any other
- * copies thereof may not be provided or otherwise made available to any
- * other person. No title to and ownership of the software is hereby
- * transferred.
- *
- *
- * ******************************************************************** */
- namespace ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Forms;
- use ModulesGarden\ProxmoxAddon as main;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Fields\NodeSelect;
- use ModulesGarden\ProxmoxAddon\App\UI\IpManagement\Providers\IpAddressProvider;
- use ModulesGarden\ProxmoxAddon\App\UI\Validators\NumberValidator;
- use ModulesGarden\ProxmoxAddon\Core\UI\Interfaces\AdminArea;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\BaseForm;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Fields;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections\HalfPageSection;
- use ModulesGarden\ProxmoxAddon\Core\UI\Widget\Forms\Sections\RawSection;
- /**
- * Description of CreateForm
- *
- * @author Pawel Kopec <pawelk@modulesgarden.com>
- */
- class UpdateForm extends BaseForm implements AdminArea
- {
- public function initContent()
- {
- $this->initIds('ipManagementUpdateForm');
- $this->setFormType('update');
- $this->addClass('lu-row');
- $this->setProvider(new IpAddressProvider);
- $this->initFields();
- $this->loadDataToForm();
- }
- protected function initFields()
- {
- $mainSection = new RawSection('mainSection');
- $mainSection->setMainContainer($this->mainContainer);
- $leftSection = new HalfPageSection('leftSection');
- $leftSection->setMainContainer($this->mainContainer);
- $rightSection = new HalfPageSection('rightSection');
- $rightSection->setMainContainer($this->mainContainer);
- //id
- $field = new Fields\Hidden('id');
- $mainSection->addField($field);
- //IP Address
- $field = new Fields\Text('ip');
- $field->addValidator(new main\App\UI\Validators\IpAddressValidator(true));
- $field->setPlaceholder('192.168.0.100');
- $mainSection->addField($field);
- //MAC Address
- $field = new Fields\Text('mac_address');
- $field->addValidator(new main\App\UI\Validators\MacAddressValidator());
- $field->setPlaceholder('E6:AA:5C:8B:DF:12');
- $mainSection->addField($field);
- //VLAN Trunks
- $field = new Fields\Text('trunks');
- $field->addValidator(new NumberValidator());
- $leftSection->addField($field);
- //Tag
- $field = new Fields\Text('tag');
- $field->addValidator(new NumberValidator(1, 4094));
- $rightSection->addField($field);
- //Subnet Mask
- $field = new Fields\Text('subnet_mask');
- $field->addValidator(new main\App\UI\Validators\IpAddressValidator(false));
- $field->setPlaceholder('255.255.255.0');
- $mainSection->addField($field);
- //Gateway
- $field = new Fields\Text('gateway');
- $field->addValidator(new main\App\UI\Validators\IpAddressValidator(false, false));
- $field->setPlaceholder('192.168.0.1');
- $mainSection->addField($field);
- //CIDR
- $field = new Fields\Text('cidr');
- $field->addValidator(new main\App\UI\Validators\CidrValidator(true));
- $field->setPlaceholder('24');
- $mainSection->addField($field);
- //Server
- $field = new Fields\Select('sid');
- $values = ["0" => main\Core\ServiceLocator::call('lang')->absoluteT('Any')];
- $values += (array)main\Core\Models\Whmcs\Server::whereIn("type", ["proxmoxVPS", "ProxmoxCloudVps"])->pluck("name", "id")->toArray();
- $field->setAvailableValues($values);
- $leftSection->addField($field);
- //Node
- $field = new NodeSelect('node');
- $field->addReloadOnChangeField('sid');
- $field->setMainContainer($this->mainContainer);
- $rightSection->addField($field);
- //Virtualization
- $field = new Fields\Select('visualization');
- $field->setAvailableValues(["Auto" => main\Core\ServiceLocator::call('lang')->absoluteT('Auto'), "KVM" => "KVM", "LXC" => "LXC"]);
- $mainSection->addField($field);
- //Private Address
- $field = new Fields\Switcher('private');
- $mainSection->addField($field);
- $this->addSection($mainSection);
- $this->addSection($leftSection);
- $this->addSection($rightSection);
- }
- protected function getDefaultActions()
- {
- return ['update'];
- }
- }
|