Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Appearance

PHPrunner32x32     PHPRunner manual


Hide controls on Add/Edit pages, based on the username

Scroll Prev Next More

 

To hide controls on Add/Edit pages, based on the username, use the following code in the Add Page: BeforeDisplay and/or Edit Page: BeforeDisplay event.

 

Note: Change red values to match your project.

Example 1

To show the "Horsepower" field edit control only if the username equals "admin", use the following code:

 

if (Security::getUserName()!="admin")
  $pageObject->hideField("Horsepower");

Example 2

To show the "Horsepower" field edit control only if the current user belongs to the admin group, use the following code:

 

if (Security::isAdmin())
  $pageObject->hideField("Horsepower");

 

Note: This code sample works only with static permissions.

 

3. To hide the "Horsepower" field edit control placed on tab or folding section on the Edit/Add/View page, use the following code:

 

$pageObject->hideField("Horsepower");

See also:

Security API

JavaScript API: hideField()

Security API: isAdmin

Security API: getUserName

JavaScript API: hide()

RunnerPage class: hideItem()

JavaScript API: toggleItem()

 

Created with Help+Manual 7 and styled with Premium Pack Version 3 © by EC Software