Set dynamic field default value

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
jzb
User
Posts: 3

Set dynamic field default value

Post by jzb »

Dear PHPMaker users,

I have 2 tables :

  • user_settings (with a field called "user_settings_zone")
  • events (with a field called "events_zone")

When user add or edit an event, "events_zone" value must be automatically set as "user_settings_zone" value.

BR

Jam


mobhar
User
Posts: 11712

Post by mobhar »

Your post is not clear enough. What are the control of both fields? Are they using Combobox (Select) control? If so, then you should populate the data from another lookup table that contains all the timezone records.

You may write jQuery code and put it in "Startup Script" based on change event of the Combobox control to set the value to another field. Please "Server Events and Client Scripts" topic from PHPMaker Help menu for more info.


jzb
User
Posts: 3

Post by jzb »

"user_settings_zone" and "events_zone" are both TEXT.

I cannot use Lookup table because this will affect all records related to "user_settings_zone" value.

Let me clarify. Here is a detailed example :

  1. The User set "user_settings_zone" value to "London"
  2. From this step, all events created or modified by the User will have "events_zone" = "London"
  3. The User set "user_settings_zone" value to "Tokyo"
  4. From this step, all events created or modified by the User will have "events_zone" = "Tokyo"
    etc...

How and Where to set default value in add/edit events form ? "events_zone" value = "user_settings_zone" value

Hope that clarifies


mobhar
User
Posts: 11712

Post by mobhar »

You may simply use jQuery "keydown" and/or "keyup" to set the same value into another control in the form.

Put that code in "Startup Script" of "Add Page" and/or "Edit Page". Just Goole for the code sample out there.


jzb
User
Posts: 3

Post by jzb »

Thanks for your feedbacks mobhar.

After further investigations, I found that SESSION is the right solution.

  • Server Events > Global > All Pages > User_Validated
    $_SESSION['user_settings_zone'] = $rs['user_settings_zone'];

For user_settings table :

  • Server Events > Table-Specific > Common > Row_Updated
    $_SESSION['user_settings_zone'] = $rs['user_settings_zone'];

For events table :

  • Server Events > Table-Specific > Common > Add/Copy Page > Page_DataRendering
    $this->events_zone->EditValue = $_SESSION['user_settings_zone'];

Post Reply