Page 1 of 2
Query - Dynamic saving
Posted: Sun Mar 07, 2021 11:30 am
by Dalkeith
As pretty much a complete beginner I am interested in implementing something that automatically saves the field on exit of the field within the edit form..
I did find something by Janusz that resembled what I needed but I really could do with a complete beginners guide.
Could someone point me / give some guidance for an efficient solution?
Ta
Re: Query - Dynamic saving
Posted: Sun Mar 07, 2021 11:52 am
by kev1n
Hi,
If the form is not saved yet you'd have to save it first to create the record in the database.
Use the onblur event to detect when an object loses focus.
(Add this event in the objects's Custom Code tab)
Then call a PHP procedure with nuRunPHPHidden() to save the field to the db. Before executing the Procedure, set a Hash Cookie with nuSetProperty() to know which field has to be saved.
Let me know if you need more details.
Re: Query - Dynamic saving
Posted: Mon Mar 08, 2021 1:11 pm
by apmuthu
A screenshot and a list of functions to be called would be in order.
Re: Query - Dynamic saving
Posted: Tue Mar 09, 2021 5:55 pm
by Dalkeith
Thank you Kevin Apmuthu I will have a go at the weekend.
Re: Query - Dynamic saving
Posted: Sat Mar 20, 2021 5:48 pm
by kev1n
Were you able to implement this or do you need more guidance?
Re: Query - Dynamic saving
Posted: Mon Mar 22, 2021 12:28 pm
by Dalkeith
Hi Kevin I ran out of time but I didn't understand the instructions if I am honest. I was hoping to have some quick fix to make all edit forms dynamically save on field exit.
Re: Query - Dynamic saving
Posted: Mon Mar 22, 2021 2:21 pm
by kev1n
I created a small autosaving demo at
https://test.nubuilder.cloud/
It might not be perfect yet but should help you get going.
Login credentials:
User: test
Password: nutest
User Home -> autosave Button
It makes use of the autosaveForm PHP Procedure:
https://test.nubuilder.cloud/index.php? ... e43b9b3be3
The logic at the moment is as follows:
The first time a blur event occurs and a field's value is changed, the (entire) form is saved to create a record in the table.
For each subsequent blur event only the edited field is saved by executing the autosaveForm Procedure. This is also faster than saving the whole form.
Re: Query - Dynamic saving
Posted: Mon Mar 22, 2021 8:47 pm
by Dalkeith
Thank you Kevin I will try it out
Re: Query - Dynamic saving
Posted: Tue Mar 23, 2021 8:54 pm
by kev1n
Demo updated: The focus is retained when the form is saved for the first time.
Re: Query - Dynamic saving
Posted: Tue Mar 23, 2021 9:38 pm
by Dalkeith
Works really really great Kev1n
I do note that the date field doesn't seem to work not sure why