gorriecoe / silverstripe-menu

Adds multiple menus that are defined via yml and managed via the cms.
BSD 3-Clause "New" or "Revised" License
5 stars 18 forks source link

BUG Fix issue with non-admins not being able to create new links #11

Closed tractorcow closed 2 years ago

tractorcow commented 3 years ago

When a MenuLink() object is created via gridfield, it does not have either a ParentID nor a MenuSetID field. This causes canEdit() on the object to return false (except for ADMIN) users. The form is thus read-only and the user cannot create the record.

To resolve this, we ensure that MenuSet::canEdit() only checks for the specific permission if it is saved to the database. If it's a singleton, fail back to cms permissions.

Note that MenuLink::canCreate() still safely checks if the object can be created for a specific menuset. canEdit() unfortunately is called during the form rendering, which doesn't know about that parent.

cc @gorriecoe for review.

tractorcow commented 3 years ago

I also pushed up a fix for "Children" tab being visible on menus that haven't been saved yet.