Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Info.php
Go to the documentation of this file.
1 <?php
7 
13 class Info extends \Magento\Backend\Block\Widget\Form\Generic implements \Magento\Backend\Block\Widget\Tab\TabInterface
14 {
18  const IDENTITY_VERIFICATION_PASSWORD_FIELD = 'current_password';
19 
23  public function getTabLabel()
24  {
25  return __('Role Info');
26  }
27 
31  public function getTabTitle()
32  {
33  return $this->getTabLabel();
34  }
35 
39  public function canShowTab()
40  {
41  return true;
42  }
43 
47  public function isHidden()
48  {
49  return false;
50  }
51 
55  public function _beforeToHtml()
56  {
57  $this->_initForm();
58 
59  return parent::_beforeToHtml();
60  }
61 
65  protected function _initForm()
66  {
68  $form = $this->_formFactory->create();
69 
70  $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Role Information')]);
71 
72  $fieldset->addField(
73  'role_name',
74  'text',
75  [
76  'name' => 'rolename',
77  'label' => __('Role Name'),
78  'id' => 'role_name',
79  'class' => 'required-entry',
80  'required' => true
81  ]
82  );
83 
84  $fieldset->addField('role_id', 'hidden', ['name' => 'role_id', 'id' => 'role_id']);
85 
86  $fieldset->addField('in_role_user', 'hidden', ['name' => 'in_role_user', 'id' => 'in_role_userz']);
87 
88  $fieldset->addField('in_role_user_old', 'hidden', ['name' => 'in_role_user_old']);
89 
90  $verificationFieldset = $form->addFieldset(
91  'current_user_verification_fieldset',
92  ['legend' => __('Current User Identity Verification')]
93  );
94  $verificationFieldset->addField(
95  self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
96  'password',
97  [
98  'name' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
99  'label' => __('Your Password'),
100  'id' => self::IDENTITY_VERIFICATION_PASSWORD_FIELD,
101  'title' => __('Your Password'),
102  'class' => 'input-text validate-current-password required-entry',
103  'required' => true
104  ]
105  );
106 
107  $data = ['in_role_user_old' => $this->getOldUsers()];
108  if ($this->getRole() && is_array($this->getRole()->getData())) {
109  $data = array_merge($this->getRole()->getData(), $data);
110  }
111  $form->setValues($data);
112  $this->setForm($form);
113  }
114 
120  protected function getOldUsers()
121  {
122  return $this->_coreRegistry->registry(
123  \Magento\User\Controller\Adminhtml\User\Role\SaveRole::IN_ROLE_OLD_USER_FORM_DATA_SESSION_KEY
124  );
125  }
126 }
getData($key='', $index=null)
Definition: DataObject.php:119
setForm(\Magento\Framework\Data\Form $form)
Definition: Form.php:112
__()
Definition: __.php:13
const IDENTITY_VERIFICATION_PASSWORD_FIELD
Definition: Info.php:18