Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Restric updating field.
-
- Posts: 41
- Joined: Thu Jan 25, 2018 3:51 pm
Restric updating field.
Hi,
once data is inserted, can we restrict update on that field??
Regards,
Sandeep
once data is inserted, can we restrict update on that field??
Regards,
Sandeep
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Restric updating field.
Hi,
You can disable fields with Javascript (not so secure but simple) and in addition, to make it more secure, check by PHP if no other fields have been modified.
Add this to you form's JavaScript field:
...and something like this in PHP:
https://forums.nubuilder.cloud/viewtopic. ... ent#p17256
You can disable fields with Javascript (not so secure but simple) and in addition, to make it more secure, check by PHP if no other fields have been modified.
Add this to you form's JavaScript field:
Code: Select all
if(!nuIsNewRecord()){
// Disable all fields
$('input, select, textarea').prop('disabled', true);
// Enable just one field
$('#some_field_id').prop('disabled', false);
}
...and something like this in PHP:
https://forums.nubuilder.cloud/viewtopic. ... ent#p17256
-
- Posts: 41
- Joined: Thu Jan 25, 2018 3:51 pm
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Restric updating field.
Just add the code to your main form and all fields of your subform will also be included (/disabled)
-
- Posts: 41
- Joined: Thu Jan 25, 2018 3:51 pm
Re: Restric updating field.
Thank you very much for response Tom.
if(!nuIsNewRecord()){
// Disable all fields
$('input, select, textarea').prop('disabled', true);
// Enable just one field
$('#some_field_id').prop('disabled', false);
}
from this code #some_field_id is from main form it is working.
if i use #some_field_id subform field it is not working.
if the field name is customer_name from subform i tried with ,
customer_name,#customer_name, #customer_name#.
if(!nuIsNewRecord()){
// Disable all fields
$('input, select, textarea').prop('disabled', true);
// Enable just one field
$('#some_field_id').prop('disabled', false);
}
from this code #some_field_id is from main form it is working.
if i use #some_field_id subform field it is not working.
if the field name is customer_name from subform i tried with ,
customer_name,#customer_name, #customer_name#.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Restric updating field.
replace sub_form_id with the ID of your subform:
Code: Select all
$('[id ^=sub_form_id][id $=customer_name]').prop("disabled", false);
-
- Posts: 41
- Joined: Thu Jan 25, 2018 3:51 pm
Re: Restric updating field.
Something i must be doing wrong... I tried all the ways but no luck. Today i will try will secure way using PHP.
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Restric updating field.
It works for me, e.g. in the "Access Levels" / Tab Forms , disable all Add checkboxes:
Code: Select all
$('[id ^=accform][id $=slf_add_button]').prop("disabled", true);
You do not have the required permissions to view the files attached to this post.
-
- Posts: 41
- Joined: Thu Jan 25, 2018 3:51 pm
Re: Restric updating field.
Yeah it working now. with java script.
because of the condition if(!nuIsNewRecord()) it is not allowing me to add new sub form record if i edit main form.
I need it like:
when we edit main form it should allow us to add new subform record with all the fields enable to enter but not to edit exiting sub form field data.
will that be possible??
because of the condition if(!nuIsNewRecord()) it is not allowing me to add new sub form record if i edit main form.
I need it like:
when we edit main form it should allow us to add new subform record with all the fields enable to enter but not to edit exiting sub form field data.
will that be possible??
-
- Posts: 785
- Joined: Sun Oct 14, 2018 11:25 am
Re: Restric updating field.
That's possible. All you need to know is some JavaScript/jQuery and use functions the are documented on the wiki. https://wiki.nubuilder.cloud/ ... Javascriptsandeepgumudelli wrote: when we edit main form it should allow us to add new subform record with all the fields enable to enter but not to edit exiting sub form field data.
will that be possible??
Code: Select all
function disableSubformRows(f) {
// disable all fields of the subform grid
$('[id ^=' + f + ']').prop("disabled", true);
// enable the last row to allow new insertions
var r = nuPad3(nuSubformObject(f).rows.length - 1);
$('[id ^=' + f + r + ']').prop("disabled", false);
}
if (nuFormType() == 'edit') { // run the script if the form type is edit
if (!nuIsNewRecord()) { // disable rows if not a new record
disableSubformRows("YOUR_SUB_FORM_ID"); // <------------- replace with your subform id
}
}
Last edited by Anonymous on Thu Jul 19, 2018 2:52 pm, edited 1 time in total.