This topic is locked

How to hide controls on Add/Edit pages

9/6/2007 9:36:48 PM
PHPRunner Tips and Tricks
admin

PHPRunner 4.2

This is a two step process

  1. Proceed to the Edit page, switch to HTML mode and wrap the code section with wrappers (in bold) as shown below:
    {if $admin_user}

    <TR>

    <TD class=shade width=150>Horsepower</TD>

    <TD width=250>

    {build_edit_control field="Horsepower" value=$value_Horsepower mode="edit"}

    </TD></TR>
    {/if}


2. Now you need to implement BeforeShowEdit event and put the following code there:

$smarty->assign("admin_user", $_SESSION["UserID"]=="admin");


Horsepower edit box will be shown only if username equals "admin".
PHPRunner 5.0 (and later)
To hide Horsepower field add BeforeShowEdit event on the Events tab and put the following code there:

$xt->assign("Horsepower_fieldblock",$_SESSION["UserID"]=="admin");


Horsepower edit box will be shown only if username equals "admin".

M
mmponline 9/14/2007

This works great. How would one change the code to show the record dependant on the User's Group he/she belongs to in stead of the username.

admin 11/5/2007

Use $_SESSION["GroupID"] for this purpose.
More info about PHPRunner Session variables:

http://www.xlinesoft.com/phprunner/docs/ph...n_variables.htm

P
Phil_G 10/8/2009

Nice one... How about hiding the 'add' button if a record already exists?



PHPRunner 4.2

This is a two step process

  1. Proceed to the Edit page, switch to HTML mode and wrap the code section with wrappers (in bold) as shown below:
  2. Now you need to implement BeforeShowEdit event and put the following code there:

$smarty->assign("admin_user", $_SESSION["UserID"]=="admin");


Horsepower edit box will be shown only if username equals "admin".
PHPRunner 5.0
To hide Horsepower field add BeforeShowEdit event on the Events tab and put the following code there:
Horsepower edit box will be shown only if username equals "admin".