getgrav / getgrav/grav-plugin-admin

onAdminSave should provide field's information

Open
#1,793 4 comments 0 reactions 1 assignee Claimed by @mahagr View on GitHub
question
Dominant language
PHP
Stars
377
Forks
225
Avg merge
11h 51m
Merged PRs (30d)
4

Description

I've created a custom field intended for admin-side. The value POSTed by the widget is a `JSON.stringify()` in a hidden field, but I want to process it (mostly `json_decode()`).

For this, I hook into `onAdminSave()`.
Eg:
```php
public function onAdminSave(Event $event)
{
if (isset($event['object']->header()->form['field_selection'])) {
$event['object']->header()->form['field_selection'] = json_decode($event['object']->header()->form['field_selection'], true);
}
}
```

But this processing is bound on hardcoding the field **name**. I'd like to be able to process all instance of my-field whatever their name is.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.