Setting a group or element to readonly prior to display on a form

skyrun

Active Member
I would like to look up info about each record in a repeating list and set them to read-only in certain circumstances. my use-case is that all of the fields in the group would be read-only, but a solution where i set each element individually would work too.

i was thinking a php form plugin onCanEditGroup perhaps, that looks at the info and perhaps modifies the DOM?
 
Hmmm. No, onCanEditGroup won't work, if you are needing to process each repeat individually, as it only gets called once per group, not for each repeat.

I thought we had another candidate in onElementCanUse, which gets called from canUse() in the element model, which gets called from the right place in getGroupView(), where the repeats are being processed.

BUT ... by that point, canUse() has already been called on all the elements, so the access mask is already set and cached, so canEdit() just returns the cached value, and doesn't re-run the onElementCanUse plugins. Which is not something I want to do an end run round, as canEdit() gets called a *lot*, and running plugins from it every time would be a massive performance hit.

I spent about 45 minutes noodling around stepping though code, and I really can't find a hook anywhere that works for what you want to do. I suspect the only way would be to add another plugin hook and fire it seperately around line 4832 in the form model:

https://github.com/Fabrik/fabrik/blob/master/components/com_fabrik/models/form.php#L4830

But of course that's kind of outside the scope of subscription support, and I'd have to do some exploratory surgery to see if changing the access control on it at that point would have the desired effect.

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top