This topic is locked
[SOLVED]

How to disabled / enabled all the controls on edit page depending of User Group

8/8/2022 3:44:46 AM
PHPRunner General questions
J
jackwood author

I can Show and Hide the Controls in the BEFORE DISPLAY, But Can not Enable / Disable the Controls based on User Group

if($groups["CustomerService"])
{
$pageObject->showField("item_fg");
$pageObject->showfield("qty_fg");

$pageObject->setDisable("item_fg"); // DOESN'T WORK
$pageObject->setDisable("qty_fg"); // DOESN'T WORK

}

else

{
$pageObject->hideField("item_fg");
$pageObject->hidefield("qty_fg");
}

Sergey Kornilov admin 8/8/2022

You are inventing the syntax that doesn't exist. There is no setDisable function in PHPRunner's API.

M
macalister 8/9/2022

Hi.

You can pass the group info through a proxy (Before Display) .

$groups = Security::getUserGroups();
$pageObject->setProxyValue("groups",$groups );

And use javascript (JavaScript on Load Event) to enable or disable controls.

var item_fg = Runner.getControl(pageid,'item_fg');
var qty_fg = Runner.getControl(pageid,'qty_fg');

if(proxy.groups['CustomerService']){
item_fg.makeReadonly();
qty_fg.makeReadonly();
}
J
jackwood author 8/9/2022

Hi macalister,
your code is what I looking for. amazing, you make my day.
Thank you very much, realy appreciate.