BaseStandaloneForm.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Forms;
  3. use \ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Widget\Buttons\ButtonSubmitForm;
  4. /**
  5. * BaseForm controler
  6. *
  7. * @author Sławomir Miśkowicz <slawomir@modulesgarden.com>
  8. */
  9. class BaseStandaloneForm extends BaseForm implements \ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\AjaxElementInterface, \ModulesGarden\Servers\ProxmoxCloudVps\Core\UI\Interfaces\FormInterface
  10. {
  11. protected $id = 'baseStandaloneForm';
  12. protected $name = 'baseStandaloneForm';
  13. public function __construct($baseId = null)
  14. {
  15. parent::__construct($baseId);
  16. $this->getAllowedActions();
  17. $submitButton = new ButtonSubmitForm();
  18. $submitButton->setFormId($this->id);
  19. $submitButton->runInitContentProcess();
  20. $this->setSubmit($submitButton);
  21. }
  22. protected function loadDataToForm()
  23. {
  24. $this->loadProvider();
  25. $this->dataProvider->initData();
  26. foreach ($this->fields as &$field)
  27. {
  28. $field->setValue($this->dataProvider->getValueById($field->getId()));
  29. $avValues = $this->dataProvider->getAvailableValuesById($field->getId());
  30. if ($avValues && method_exists($field, 'setAvailableValues'))
  31. {
  32. $field->setAvailableValues($avValues);
  33. }
  34. if ($this->dataProvider->isDisabledById($field->getId()))
  35. {
  36. $field->disableField();
  37. }
  38. }
  39. foreach ($this->sections as &$section)
  40. {
  41. $section->loadDataToForm($this->dataProvider);
  42. }
  43. $this->addLangReplacements();
  44. }
  45. }