This topic is locked

Adding not linked fields

3/8/2008 6:42:41 AM
PHPRunner General questions
L
loki author

Hi, I'm wondering how can I add a editable field in a Add/Edit page, an example

Table customers

Table product

Table product description

Table languages
A customer has two languages (1 - English, 2 - Francais), I will need add two records in product_description for each record in product, but I need edit the two product description in Add/Edit product page:

  • Name (name of the product)
  • Price (price)
  • Description English ()
  • Description Francais ()
    Is there a way to do it without add fields manually (html of fields)?

J
Jane 3/11/2008

Hi,
generally it's not possible to edit two tables on the one page.
As workaround you can do the following:

  1. edit SQL query on the Edit SQL query tab and join product and product description tables,
  2. check off description (english) and description (Francais) on the add and edit pages only on the Choose fields tab,
  3. update product description table in the After record added/Before record updated events on the Events tab.

    Here is a sample for Before record updated event:
    global $conn;

    $strUpdate = "update product_description set description='".$values["description_english"]."' where productID=".$keys["productID"];

    db_exec($strUpdate);
    unset($values["description_english"]);



where description and productID are your actual field names, product_description is your actual table name.