Page 1 of 2
Edit Form - additional Save button
Posted: Thu Jan 17, 2019 1:20 pm
by Janusz
Hi,
I wanted to add additional "Save" button on the edit form and to make it show/hide depanding on the case.
So in case of new record the following code is making button visible - and
works OK
Code: Select all
if(nuIsNewRecord()){
$('#button_save').show();
}
To make the button not visible after "save" the following code is working
OK
Code: Select all
if (nuFormType() == 'edit') {
if (nuHasBeenSaved() === 1) { $('#button_save').hide(); }
}
But I am not able to properly show the button when someone stars to edit already opened form.
I was trying for example code like belowe or some other trials but with no success.
(for example the code belowe is always activating the button)
if(nuIsSaved()){
$('#button_save').show();
}
Can you please let me know how I could implement it?
Janusz
Re: Form edit identification
Posted: Thu Jan 17, 2019 2:17 pm
by kev1n
Is the button visible by default? If yes, isn't it sufficient to hide the button if you just saved the form?
Code: Select all
if (nuFormType() == 'edit') {
if (nuHasBeenSaved() === 1) {
nuHide('button_save');
}
}
Re: Form edit identification
Posted: Thu Jan 17, 2019 2:37 pm
by Janusz
By default I keep this button hidden and want to make it visible when someone will start to edit the record.
In other words - to make this button visible when the standard save button is becoming red. I was trying to use as well nuHasBeenEdited but did not get expected behavior.
Re: Form edit identification
Posted: Thu Jan 17, 2019 3:53 pm
by kev1n
Try this: shows the button if it's a new record or not just saved.
Code: Select all
if (nuFormType() == 'edit') {
if (nuIsNewRecord() || nuHasBeenSaved() == 0) {
nuShow('button_save');
}
}
Re: Edit Form - additional Save button
Posted: Thu Jan 17, 2019 7:48 pm
by Janusz
Thanks for your support, and suggestion.
I did finally following as I had some issues with the code placed just in main form only.
If someone else would like to implement addional big SAVE button (as I was requested to implement by my wife who is using that databse

)
here is the full description:
Definition of additional SAVE button, which normaly is hidden and is showing up if someone is starting new record or to modify existing record.
Create button (ID: button_save)
All/type:
Input; Input tab:
Button; Custom Code tab:
onclick nuSaveAction()
In Form properties / Custome code / JavaScript / place following code :
Code: Select all
$('#button_save').hide();
$('#button_save').css("background", "red");
if(nuIsNewRecord()){
$('#button_save').show();
}
Next
in every object on the edit form (edit fields, check boxex, etc)
in custom code, JavaScript I placed:
(potentally can be used
onchange but in such case button appears once you exit the modified field, so im my case I preffered to choose option
onclick so the button is shown up once you click inside the field)
Re: Edit Form - additional Save button
Posted: Thu Jan 17, 2019 9:08 pm
by kev1n
Janusz wrote:
Next
in every object on the edit form (edit fields, check boxex, etc)
in custom code, JavaScript I placed:
Easier like this:
Code: Select all
if (nuFormType() == 'edit') {
var inputs = $("#nuRECORD").find(":input:not([type=button])");
inputs.click(function() {
nuShow('button_save');
});
}
}
Re: Edit Form - additional Save button
Posted: Thu Jan 17, 2019 10:08 pm
by Janusz
Yeah, thanks a lot - your code is working pefectly and much, much faster than changing each object one after another.
(just one bracket to remove at the end of the code)
Re: Edit Form - additional Save button
Posted: Fri Jan 18, 2019 8:12 am
by Janusz
I noticed that select field behaves not well if the function
click is used and its better for that to use
change.
And therefore one more question, how to
exclude in the search both
button and select.
Code: Select all
...
var inputs = $("#nuRECORD").find(":input:not([type=button])");
...
because afterwards I want to add following: (but it does not work if click is assigned, puttung click to empty - is not helping as well)
Code: Select all
if (nuFormType() == 'edit') {
var inputs = $("#nuRECORD").find(":select");
inputs.change(function() { nuShow('button_save');});
}
Re: Edit Form - additional Save button
Posted: Fri Jan 18, 2019 9:04 am
by kev1n
var inputs = $("#nuRECORD").find(":input:not([type=button])").not('select');
Re: Edit Form - additional Save button
Posted: Fri Jan 18, 2019 10:17 am
by Janusz
Thanks, working fine.