How to prevent entering data in a read-only field

I’m used to that you can’t enter any data in read-only fields.

In insert mode in a scriptcase form however I can enter data and this is unwanted behaviour. The field is actually NOT read-only.

Is this a bug in Scriptcase or intended behaviour?

Who can help?

Re: How to prevent entering data in a read-only field

Read Only fields are editable in Insert Mode.
If you do not want this. Mark the “Label” Field option.

Re: How to prevent entering data in a read-only field

Mark the “Label” Field option.

What do you mean by this?
Do you mean to change the label so that it tells the user not to edit the field?

I want to display audit fields date_created and date_modified. You don’t want users to be able to change data in audit columns.

Re: How to prevent entering data in a read-only field

In the field settings you have an option to select if that field will be a “label field” or not.

Re: How to prevent entering data in a read-only field

do you need to display the fields??? if not, just hide them, i have similar audit fields, and i just put a check in the onLoad, if(sc_btn_new){ sc_field_display({create_date}, off);} That way when they insert the record they can’t see it, but when you view records, you can.

Re: How to prevent entering data in a read-only field

thanks, that’s probably what I need to do as a workaround.

Re: How to prevent entering data in a read-only field

if you do what victor said, that should work too. Just open the app and click the ‘fields’ drop down list, then select the field you want to change and in the settings, click the check box for ‘label field’. It’s right under the ‘hidden field’ option.

Re: How to prevent entering data in a read-only field

No, what victor suggests does not work for inserts. When inserting a record I can still modify fields that are marked as read-only and label field = yes.

Re: How to prevent entering data in a read-only field

o, another way you can try to do it is instead of hiding the field, in the onLoad, you can check for sc_btn_new and then use the function to make a field read only.

if (sc_btn_new)
{
sc_field_readonly({my_field});
}

Re: How to prevent entering data in a read-only field

I have had this happen as well.

I would find the code in the PHP output and see how it is create/declared.
Then create a PHP button and run the code. Play with it until you get the result you are looking for and then report the bug to SC.

Was this a new app or a converted from V4 app?

Regards,
Scott.

Re: How to prevent entering data in a read-only field

Or paste the code in a blank app and run.

Scott

Re: How to prevent entering data in a read-only field

Do not use Read-only option, but just “Label” option.
Label fields can’t be edited in insert mode.

V?tor Jamil

Re: How to prevent entering data in a read-only field

Information like this would be very helpful in the help file.

Regards,
Scott.