Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.33 KB | None | 0 0
  1. $this->setTemplate(myphtml.phtml);
  2.  
  3. <?php
  4.  
  5. namespace NamespaceModulenameBlockAdminhtmlModulenameEditTab;
  6.  
  7. /**
  8. * Modulename edit form main tab
  9. */
  10. class Main extends MagentoBackendBlockWidgetFormGeneric implements MagentoBackendBlockWidgetTabTabInterface
  11. {
  12. /**
  13. * @var MagentoStoreModelSystemStore
  14. */
  15. protected $_systemStore;
  16.  
  17. /**
  18. * @var NavGametypeModelStatus
  19. */
  20. protected $_status;
  21.  
  22.  
  23.  
  24. /**
  25. * @param MagentoBackendBlockTemplateContext $context
  26. * @param MagentoFrameworkRegistry $registry
  27. * @param MagentoFrameworkDataFormFactory $formFactory
  28. * @param MagentoStoreModelSystemStore $systemStore
  29. * @param array $data
  30. */
  31. public function __construct(
  32. MagentoBackendBlockTemplateContext $context,
  33. MagentoFrameworkRegistry $registry,
  34. MagentoFrameworkDataFormFactory $formFactory,
  35. MagentoStoreModelSystemStore $systemStore,
  36. NavGametypeModelStatus $status,
  37. array $data = []
  38. ) {
  39. $this->_systemStore = $systemStore;
  40. $this->_status = $status;
  41. parent::__construct($context, $registry, $formFactory, $data);
  42. }
  43.  
  44. /**
  45. * Prepare form
  46. *
  47. * @return $this
  48. * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  49. */
  50.  
  51.  
  52. protected function _prepareForm()
  53. {
  54. /* @var $model NavGametypeModelBlogPosts */
  55. $model = $this->_coreRegistry->registry('gametype');
  56.  
  57. $isElementDisabled = false;
  58.  
  59. /** @var MagentoFrameworkDataForm $form */
  60. $form = $this->_formFactory->create();
  61.  
  62. // $form->setHtmlIdPrefix('page_');
  63.  
  64. $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Game Information')]);
  65.  
  66. if ($model->getId()) {
  67. $fieldset->addField('nav_game_type_id', 'hidden', ['name' => 'nav_game_type_id']);
  68. }
  69.  
  70. /* $fieldset->addField(
  71. 'title',
  72. 'text',
  73. [
  74. 'name' => 'title',
  75. 'label' => __('Title'),
  76. 'title' => __('Title'),
  77. 'required' => true,
  78. 'disabled' => $isElementDisabled
  79. ]
  80. );*/
  81.  
  82. $this->setTemplate('myphtml.phtml');
  83.  
  84. if (!$model->getId()) {
  85. $model->setData('is_active', $isElementDisabled ? '0' : '1');
  86. }
  87.  
  88. $form->setValues($model->getData());
  89.  
  90. $this->setForm($form);
  91.  
  92. return parent::_prepareForm();
  93. }
  94.  
  95. /**
  96. * Prepare label for tab
  97. *
  98. * @return MagentoFrameworkPhrase
  99. */
  100. public function getTabLabel()
  101. {
  102. return __('Game Information');
  103. }
  104.  
  105.  
  106. /**
  107. * Prepare title for tab
  108. *
  109. * @return MagentoFrameworkPhrase
  110. */
  111. public function getTabTitle()
  112. {
  113. return __('Game Information');
  114. }
  115.  
  116. /**
  117. * {@inheritdoc}
  118. */
  119. public function canShowTab()
  120. {
  121. return true;
  122. }
  123.  
  124. /**
  125. * {@inheritdoc}
  126. */
  127. public function isHidden()
  128. {
  129. return false;
  130. }
  131.  
  132. /**
  133. * Check permission for passed action
  134. *
  135. * @param string $resourceId
  136. * @return bool
  137. */
  138. protected function _isAllowedAction($resourceId)
  139. {
  140. return $this->_authorization->isAllowed($resourceId);
  141. }
  142.  
  143. public function getTargetOptionArray(){
  144. return array(
  145. '_self' => "Self",
  146. '_blank' => "New Page",
  147. );
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement