Filter selection affects the field selection when adding or editing (v2023)

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

Filter selection affects the field selection when adding or editing (v2023)

Post by Wolf »

PHPMaker 2023/2024
the filter selection affects the field selection when adding or editing.
int field with selection 1 - One, 2 - Two
if in list Page Filter column is not checked all working good.
if in list Page Filter column is checked
then i add field is select 1 - One also in edit page.


motfs
User
Posts: 258

Post by motfs »

Is the field set up as User Values or Use Lookup Table? Show your table and field schema and field settings so that other can simulate the issue you mentioned.


Wolf
User
Posts: 77

Post by Wolf »

mysql:
test_field int DEFAULT NULL

phpmaker:
fields
on field select Filter

Edit tag - Select
User Values
1 | First
2 | Second

when I click the add or edit button, “First” is already selected in the field


mobhar
User
Posts: 11727

Post by mobhar »

Did you use Checkbox or Radio Button control?


Wolf
User
Posts: 77

Post by Wolf »

No only Select


mobhar
User
Posts: 11727

Post by mobhar »

If you want to keep Filter option is enabled under Fields setup -> List column, and you don't want option 1 is selected when Add page is loaded, then you may simply put this following code in Startup Script under Add Page:

$("#x_test_field").val(""); // initial value always blank

Wolf
User
Posts: 77

Post by Wolf »

Okay, on the add page we get an empty field. This is good.
But if we click "Edit" on the row with a blank field, we get option 1.
ok, let’s add our script to Startup Script under “Edit Page”.
We got: if we edit a row with an empty field - good
if we edit a row with field 1, 2 or 3 selected - we will get an empty field - not good


mobhar
User
Posts: 11727

Post by mobhar »

You should only implement it in Add Page, not in Edit Page, because in Edit Page, you have already had the current data for that field.


mobhar
User
Posts: 11727

Post by mobhar »

If in your Edit Page there is no data yet for that field, and you want to add that code, then you need to check whether the field is not empty or not. If empty, then implement that logic.


Wolf
User
Posts: 77

Post by Wolf »

Fixed in 2024.9


Post Reply