TopSection.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Sections;
  3. use ModulesGarden\ProxmoxAddon\App\Services\Cloud\ProductService;
  4. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\AccountSummary\Providers\AccountSummaryProvider;
  5. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\Validators\HostnameValidator;
  6. use ModulesGarden\Servers\ProxmoxCloudVps\App\UI\VmCreate\Fields\OsTemplateSelect;
  7. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Text;
  8. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Fields\Textarea;
  9. use ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms\Sections\RawSection;
  10. use function ModulesGarden\Servers\ProxmoxCloudVps\Core\Helper\sl;
  11. class TopSection extends RawSection
  12. {
  13. use ProductService;
  14. public function initContent()
  15. {
  16. //name
  17. $field = new Text('name');
  18. $field->addValidator(new HostnameValidator());
  19. $this->addField($field);
  20. //osTemplate
  21. if($this->configuration()->isPermissionOsTemplate() || $this->configuration()->isLxc()){
  22. $field =new OsTemplateSelect('osTemplate');
  23. $field->notEmpty();
  24. $this->addField( $field);
  25. }
  26. //description
  27. $field = new Textarea('description');
  28. $field->setRows(2);
  29. $field->replaceClasses(['lu-m-t-1x lu-m-b-0x']);
  30. $this->addField($field);
  31. $provider = new AccountSummaryProvider();
  32. $this->customTplVars['bars'] = $provider->read();
  33. }
  34. }