TopSection.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. use ProductService;
  13. public function initContent() {
  14. //name
  15. $field = new Text('name');
  16. $field->addValidator(new HostnameValidator());
  17. $this->addField($field);
  18. //osTemplate
  19. if($this->configuration()->isPermissionOsTemplate() || $this->configuration()->isLxc()){
  20. $field =new OsTemplateSelect('osTemplate');
  21. $field->notEmpty();
  22. $this->addField( $field);
  23. }
  24. //description
  25. $field = new Textarea('description');
  26. //$field->unsetShowTitle();
  27. //$field->setPlaceholder(sl('lang')->tr('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. }