This topic is locked

Lookup / Read Only Field

4/14/2009 8:24:46 PM
PHPRunner General questions
S
Stucco author

I have two tables with a one to many relationship. I have Customers && Shipments. One customer will have many shipments. I only display Customers at the entry level, and the way to reach shipments is by going through customers. This means I have the master table of customers. I have a customer_id field as the first field of a shipment, and this is pre-selected to the correct customer. I do not want them to be able to change this. I also need a lookup though, because the stored id value is an int but the display should be the customer's name.
If I choose read only I get the correct int id, but it is not the text name.

If I choose lookup table then then I see the name, but the value can be changed.
How can I show the customer name in either a disabled dropdown or plain text?
Thank you very much

J
Jane 4/15/2009

Hi,
you can set up this field as disabled using custom JavaScript code.

Here is a sample:

<script>

document.forms.editform.value_FieldName.disabled = true;

</script>



You can add this code on the Visual Editor tab in HTML mode.

S
Stucco author 4/16/2009

Thank you so much for your help. This solution worked perfectly. I edited and added the code to the add page and edit page and it worked perfectly there. I have a question though. How would I add it to the inline add and inline edit portions?
Maybe this would be easier if it was a plain text field that showed the customer_name instead of customer_id?

J
Jane 4/16/2009

Hi,
you can do the following:

  • join main and lookup tables on the Edit SQL query tab,
  • set up joined field on the list page only on the Choose pages tab.

    In this case you'll see joined value as readonly on the list page (Inline edit/add mode).

S
Stucco author 4/23/2009

Hi,

you can do the following:

  • join main and lookup tables on the Edit SQL query tab,
  • set up joined field on the list page only on the Choose pages tab.

    In this case you'll see joined value as readonly on the list page (Inline edit/add mode).


This is perfect and it is working well for the editing. I have only one more question. How do I make it work for the adding as well. When I add it no longer places in the default value because I suspect the master > child relationship is no longer obvious.
I have
Customer

id

customer_name
Shipment

id

customer_id
And user will always be coming into shipment from customers so there will always be a master table. I want the customer_name always set to the master record and never editable in either add or edit either inline or on the individual page.
Thank you so much for your help!

S
Stucco author 4/28/2009

I take it there is not a way to do such a task?