How can I add a new field which has an integer value into admin user info?
I want to add a dropdown on admin user edit form, to select any one admin user which has 'ABC' role, and that will be saved with that admin user, for that, I found a way that we can add a new column into the "admin/user" table and save that selected value when admin user edited, not on admin user create.
How can achieve this functionality with the custom module?
I used below code and its saved manager id in table but in edit form it will not showing selected value. code as below :
protected $manageData;
public function __construct(
\Name\Module\Model\Entity\Attribute\Source\ManageData $manageData
) {
$this->manageData = $manageData;
}
/**
* Get form HTML
*
* @return string
*/
public function aroundGetFormHtml(
\Magento\User\Block\User\Edit\Tab\Main $subject,
\Closure $proceed
)
{
$form = $subject->getForm();
if (is_object($form)) {
$baseFieldset = $form->addFieldset('admin_manageData', ['legend' => __('Manager Information')]);
$baseFieldset->addField(
'manageData',
'select',
[
'name' => 'manageData',
'label' => __('Select Manager'),
'title' => __('Select Manager'),
'values' => $this->manageData->getAllOptions(), // it has array of all the admin users with role 'Manager'
'class' => 'select'
]
);
$subject->setForm($form);
}
return $proceed();
}
Thanks.