phpgravpimple

Modify admin configuration values on save


I have created a configuration form in Grav's admin panel, and I want to extend/modify some of it's values on save. More precisely, I have a list form element that looks like this in the blueprint:

topics:
  type: list
  fields:
    .name:
      type: text
    .unique_id:
      type: text
      readonly: true
      default: generate_on_save

On save, I want to replace all generate_on_save values with a unique id. I tried to hook into the onAdminSave Event, but the Event Object contained just an instance of \Grav\Common\Data\Blueprint and no actual form data. I then tried to modify the request object, but when I register the modified request in the grav container, I get an error Cannot override frozen service 'request'.

How can I accomplish this task?


Solution

  • I did the following which works fine: