Read Only Fields

4 posts by 3 authors in: Forums > CMS Builder
Last Post: December 2, 2013   (RSS)

By Dave - November 28, 2013

Hi Rob,

"System Field" just makes the field harder to accidently modify in the field editor (you need to turn on "Enable System Field Editing") from the Advanced Commands menu on the bottom left.

And you're right, "Admin Only" doesn't really do it either.

Probably the easiest would be to write a plugin that hooks in to 'record_presave' and if there's an $oldRecord to load it and overwrite select fields like this: 

if ($oldRecord) { 
  $_REQUEST['createdByUser'] = $oldRecord['createdByUser];
  $_REQUEST['etc'] = $oldRecord['etc];
}

Basically overwriting whatever was submitted by the user for those fields with whatever is already in the database.

Hope that helps!

Dave Edis - Senior Developer
interactivetools.com

By Djulia - November 29, 2013 - edited: November 29, 2013

Hi Rob,

>Is there an inbuilt function to set certain fields within a schema as read only?
I do not know if I understand your request correctly but, I use jQuery to make an fields read only (in field description or prefix).

$('input[name=myfield]').attr('readonly', 'readonly');

also .prop() function (jQuery 1.6+)

http://api.jquery.com/prop/

@Dave - I benefit from this occasion to ask you whether the version of jquery will be updated in a forthcoming version?

Thanks!

Djulia

By Dave - December 2, 2013

@Djulia, Thanks for the suggestion, Yes, I'll put that on the list for the next release and we'll get that taken care of.

Dave Edis - Senior Developer
interactivetools.com