Form.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Integration\Block\Adminhtml\Integration\Edit;
  7. use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
  8. use Magento\Integration\Controller\Adminhtml\Integration;
  9. /**
  10. * @SuppressWarnings(PHPMD.DepthOfInheritance)
  11. */
  12. class Form extends \Magento\Backend\Block\Widget\Form\Generic
  13. {
  14. /**
  15. * Prepare form before rendering HTML
  16. *
  17. * @return $this
  18. */
  19. protected function _prepareForm()
  20. {
  21. /** @var \Magento\Framework\Data\Form $form */
  22. $form = $this->_formFactory->create(
  23. ['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]
  24. );
  25. $integrationData = $this->_coreRegistry->registry(Integration::REGISTRY_KEY_CURRENT_INTEGRATION);
  26. if (isset($integrationData[Info::DATA_ID])) {
  27. $form->addField(Info::DATA_ID, 'hidden', ['name' => 'id']);
  28. $form->setValues($integrationData);
  29. }
  30. $form->setUseContainer(true);
  31. $this->setForm($form);
  32. return parent::_prepareForm();
  33. }
  34. }