Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

Custom button on edit form when editing existing record only

Questions related to using nuBuilder Forte.
Post Reply
absalom
Posts: 25
Joined: Sat Apr 03, 2021 3:50 pm

Custom button on edit form when editing existing record only

Unread post by absalom »

Hi, newbie here.

I have an "edit" form which for adding new records as well as editing existing records. Furthermore, once "Save" has been clicked, the new record now is an "existing record".

I would like to add a button redirecting to a separate "edit form" for creating a new record in a second table, but since the primary key of the currently edited record will be a foreign key in the second form (reached by clicking the button), I would like the button to be unclickable (or even hidden) as long as the current record hasn't be saved into the database.

A still better requirement would also to show some warning message if the user has modified some fields in the current record, and then tries to click the button for being redirected to the second form without having previously saved his/her modifications.

Also, how can I build my second form for managing the foreign key? I would like to have this (possibly hidden) field to be automatically set to the primary key of the initial record.

How can I do such a thing?
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: Custom button on edit form when editing existing record

Unread post by kev1n »

Hi and welcome to nuBuilder!

To hide your button when the form is loaded, add this JavaScript to your form's Custom Code.

Replace 'your_button_id with the ID of your button. Use nuEnable() instead of nuShow() to enable/disable it instead of showing/hinding.

Code: Select all

if (nuFormType() == 'edit') {
   nuShow('your_button_id', ! nuIsNewRecord());
}
Are you openening the second form in a Popup window or new tab?
Post Reply