This topic is locked
[SOLVED]

 Hiding fields in JS Onload event

1/30/2019 3:01:00 PM
PHPRunner General questions
T
thamestrader author

I am having some difficulties with hiding fields on Add and Edit pages in v10. I have converted my application from v9, it is a simple order application where ordering a widget requires the record to list the components that make up the widget, this is done by autofill. The autofilled fields are included on the Add and Edit pages but are hidden on the pages by the JS Onload event.
In v9 I have used the Lookup wizard on the Item ordered field and configured the Autofill to populate the component fields, then in the JS Onload I have the following code
// Hide fields that are not relevent to the user

$("tr[data-fieldname='single_adult']").hide();

$("tr[data-fieldname='add_adult']").hide();

$("tr[data-fieldname='single_child']").hide();

$("tr[data-fieldname='add_child']").hide();
I can no longer remember where I got this code from, as I can't find it any of the xlinesoft documentation for PHPRunner, and I certainly don't know enough JS to have invented it myself. However it all works as intended. The hidden fields are autofilled and saved in the record in the table.
In v10 with Bootstrap the above code doesn't hide the fields, what does hide the fields is this code:
// Hide fields that are not relevent to the user

pageObj.hideField("single_adult");

pageObj.hideField("add_adult");

pageObj.hideField("single_child");

pageObj.hideField("add_child");
This is exactly as shown in the manual, so quite happy with that.
The problem is that when the fields are hidden then the autofilled values are not saved, if I disable the hide then the fields are autofilled and saved as expected.
Anyone any ideas what I may be doing wrong in v1o?

admin 1/30/2019

Hidden fields will not autofill. This is how it supposed to work by design. You have two options here.

  1. Make those fields readonly.
  2. Or in your BeforeAdd/BeforeEdit event run a SQL query to retrieve data from the lookup table based on selected value and then populate those fields manually.

$values["single_adult"]="something";

$values["add_adult"]="something else";

...
T
thamestrader author 1/30/2019



Hidden fields will not autofill. This is how it supposed to work by design. You have two options here.

  1. Make those fields readonly.
  2. Or in your BeforeAdd/BeforeEdit event run a SQL query to retrieve data from the lookup table based on selected value and then populate those fields manually.

$values["single_adult"]="something";

$values["add_adult"]="something else";

...




Thanks for the reply, I'll code the lookup and populate manual in the Before Add/Edit events.