Read Only Fields

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

By rjbathgate - November 24, 2013

Hey,

Is there an inbuilt function to set certain fields within a schema as read only?

I thought there was... but the System Field options and Admin Only doesn't achieve this - moreso just hides the fields altogether if non admin.

As well as setting some fields as read only, also want to disable the ability to amend the 'createdByUser' field.

Will do via a plugin if needbe, but wanted to see if I'm missing the existing functionality somewhere.

Cheers

Rob

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 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