Lookup Filter by Parent Fields?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
mpol_ch
User
Posts: 877
Location: Switzerland

Lookup Filter by Parent Fields?

Post by mpol_ch »

hello

I have the following table

wishedates (desired_start_date DATE, desired_end_date DATE suggestion DATE)

The field suggestion is using lookup table test_find with "Link field" d (Date). This is showing me all the available dates to boom such 02.02.2015, 03.02.2015,...

Now: When I want to add a record intom my wishdates table eq. wishdatesadd.php then I have the following three fields:

desired_start_date (Date Picker)
desired_end_date (Date Picker)
suggestions (Drop Down with dates like, 02.02.2015,03.02.2015....)

When I select the date 02.02.2015 for desired_start_date and for desired_end_date then It should show me in field suggestions only the date (02.02.2015)

There for I am entering the following code into file "Filter" under Lookup Table with expectation when I enter the desired_stat_date and desired_end_date then the suggestions will be filtered.

(CurrentPageID() == "add") ? "d BETWEEN '". CurrentPage()->desired_start_date->CurrentValue ."' AND '". CurrentPage()->desired_end_date->CurrentValue ."' " : ""

When I enter the following code then my suggestion table is correct but I can not define the desired_start_date...

(CurrentPageID() == "add") ? "d BETWEEN '2015-02-02' AND '2015-02-02' " : ""

I appreciate much your help. Thanks anyway. I am not sure here if I am doing correct things here? If this way is correct with PHPMaker?

thanks
mpol_ch


mobhar
User
Posts: 11745

Post by mobhar »

Google for "jquery fill select option from two dates range".


danielc
User
Posts: 1601

Post by danielc »

mpol_ch wrote:
(CurrentPageID() == "add") ? "d BETWEEN '". CurrentPage()->desired_start_date->CurrentValue
."' AND '". CurrentPage()->desired_end_date->CurrentValue ."' " : ""

There is no CurrentValue for table filter (server side) as the selection is on client side. You may consider to use Dynamic Selection List feature. The generated script for add page will be (for example, in demo project, cars table, use trademark field and model field as parent of HP field which is enabled with "Use Ajax"):

// Call Lookup selecting
$cars->Lookup_Selecting($cars->HP, $sWhereWrk);
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " LIMIT " . EW_AUTO_SUGGEST_MAX_ENTRIES;
?>
<input type="hidden" name="q_x_HP" id="q_x_HP" value="s=<?php echo ew_Encrypt($sSqlWrk) ?>&f1=<?php echo ew_Encrypt("Trademark IN ({filter_value})"); ?>&t1=3&f2=<?php echo ew_Encrypt("Model IN ({filter_value})"); ?>&t2=200">

You can modify the generated add page for f1 and f2. Change IN to > for f1 and IN to < for f2 in your case.


Post Reply