This topic is locked

How to hide / show control base on exisitng value

1/25/2010 4:10:00 PM
PHPRunner General questions
A
acpan author

If i want to hide a few controls on the Edit form base on

exiting values in other field, how should i do it.
Eg. If the table row has a value for contact_type = "Tel", then i only want to

show "Tel" and hide "Fax" field and "Mobile" field in the edit form.
Any advice is appreciated.
Thanks

acpan

J
Jane 1/26/2010

Hi,
use Edit page: Before display event to hide/show fields on the edit page.

Here is a sample:

http://www.asprunner.com/forums/topic/6196-how-to-hide-controls-on-addedit-pages/

A
acpan author 1/27/2010

Hi Jane, thanks for your reply. i have copied the answer here for the sake of discussion.
I need to check the value of current edited record,

and apply the hide method. The method mentioned below

is to use the Session variable $_SESSION["UserID"]=="admin".
Would it be something like $data["field1"] for current record?
i.e. $xt->assign("Horsepower_fieldblock",$data["field1"] == 1);
Many thanks

acpan

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
To hide Horsepower field add BeforeShowEdit event on the Events tab and put the following code there:
Quote

$xt->assign("Horsepower_fieldblock",$_SESSION["UserID"]=="admin");
Horsepower edit box will be shown only if username equals "admin".