Structure field: disable add/delete row only?


In a specific type of page, I programmatically populate a structure field regarding a another structure field defined elsewhere in the panel.

I would like that users with role “A” were able to edit fields from this structure field but unable to add or delete a row in this structure field.

Is there a way to achieve this?
Thanks for your advises :slight_smile:

Certainly not out of the box, at least not in a nice way. We don’t even have editing options per role on the field level, anyway.

You can definitely set a max limit for the number of entries. And you could probably use a pre update hook to check if the number of entries is still the same as before, but this only kicks in after the user has already tried to remove an entry. It would work to prevent deleting entries, but is not very user friendly. If you combine it with some info or help text, you can at least warn the user to not even try and delete stuff. If they do it anyway and fail, too bad.

Maybe if I replace structure field rows by sub-pages, I probably could achieve something similar with the new role permissions settings developed in the 3.2 Kirby version :thinking:

If you use subpages, you can prevent deletion, anyway.

Yes but as I use hook to delete/add rows in the structure field if the admin user modified the “original” structure field from which the second structure field is populated, I can’t set page delete to false.

But with Kirby 3.2 I will be able to set delete page to false for role “A” and delete page to true for admin, so my hook will do the job if the admin user change number of row in the “original” structure field I’m right?

We’ll see. We need an option to override blueprint settings programmatically, hope that will come in 3.2 as well.

I found a feature that max: true by coincidence :slight_smile:
This provide disable to create new item. But to disable delete min: true not working :frowning:
I think more management features should come to structure field.
Of course it doesn’t allow adding items when max is true


@ahmetbora Excactly, that’s what I already mentioned above in my first post…

I am looking for the same feature:
I would like to have a structure (or any type of field) that has 4 initial values (text used as keys) where the only a textarea can be changed
The 4 default items should not be deleted, nor should there be any new entered.
Using max: 4 works, but min: 4 leads to have structure-rows deleted and only an error show (red border)

@gork I think at the moment you have no other choice than either using four separate fields or try to tinker with a copy of the structure field (remove the remove button, for example). Or create a custom field.

Or simply hide the remove button via CSs.