This topic is locked

Lookup wizard and display the value as read only

4/10/2008 7:54:45 PM
PHPRunner General questions
F
Fawaz author

I have field called service_id, and instead of display service_id, I want to display service_name.

So, I used Lookup wizard for this task.
However, I want to display the value "service_name" as read only. How can I do this?
Thanks,

Fawaz

J
Jane 4/11/2008

Fawaz,
you can do the following:

  1. set up field as readonly on the "Edit as" settings dialog on the Visual Editor tab,
  2. add Edit page: Before display event on the Events tab.

    Here is a sample:
    $var = $smarty->get_template_vars("value_service_id");

    global $conn;

    $str = "select service_name from LookupTable where service_id=".$var;

    $rs = db_query($str,$conn);

    $data = db_fetch_array($rs);
    global $readonlyfields;

    $readonlyfields["service_id"] = $data["service_name"];

C
ckranichDevClub member 5/6/2008

Fawaz,

you can do the following:

  1. set up field as readonly on the "Edit as" settings dialog on the Visual Editor tab,
  2. add Edit page: Before display event on the Events tab.

    Here is a sample:


This works very well for me too.

But if I want to combine this with dependent fields, it fails.
sample: prodline table

PROGDIMID ( pointer to another table; want this to be read only here)

PROD1 (dropdown dependent eg. filtered after PROGDIMID)

PROD2 ( " same " )
-> if I do the trick with the read only, I break the dependend fields

(It looks AS IF A DEPENDENT FIELD MAY NOT DEPEND ON A READ ONLY FIELD - please confirm)
Best Regards,
Christian

C
ckranichDevClub member 5/6/2008

Hello,
It seams that I have found a trick around this:

-> Duplicate a field in the SQL query using AS

-> Delete one of the fields(that one not used for Read only) in Visual Editor

.....

FIELD,

FIELD AS ROFIELD,

.....
important:

ROFIELD is set to Readonly and populated in Event

also might be used in list pages
FIELD is deleted in visual Editor (but might still be referenced for category selection)
Greetings from Europe,
Christian

L
lordkain2 7/29/2008

Hello ckranich, can you be more clear, I'm a newbie.
I use this code:
$var = $smarty->get_template_vars("value_Id_Ofi");

global $conn;

$str = "select Nombre from ofic where Id_Ofic=".$var;

$rs = db_query($str,$conn);

$data = db_fetch_array($rs);
global $readonlyfields;

$readonlyfields["Id_Ofi"] = $data["Nombre"];
and works, but how I use this with dependent fields, thanks