TopSection.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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->unsetShowTitle();
  29. //$field->setPlaceholder(sl('lang')->tr('Description'));
  30. $field->setRows(2);
  31. $field->replaceClasses(['lu-m-t-1x lu-m-b-0x']);
  32. $this->addField($field);
  33. $provider = new AccountSummaryProvider();
  34. $this->customTplVars['bars'] = $provider->read();
  35. }
  36. }