editor insert issue
editor insert issue
I am an editor user.
Receives FULLURL information from editor fields.
(ex: https://www.google.com/search?q=datatable)
In the fullurl information in the save file
I want to save only the baseurl information separately.
(ex:https://www.google.com)
Can I work with the fullurl I entered without requesting an additional baseurl?
fields: [
{
"label": "url:", "name": "fullurl",
}
]
== It's ok ==
$editor->fields(Field::inst('fullurl'));
== here problem!! ==
$editor->fields(Field::inst('baseurl')
->setFormatter(function($value, $data) {
$pattern = '/^(https?:\/\/[^\/]+)/';
if (preg_match($pattern, $value, $matches)) {
$baseUrl = $matches[1];
}
return $baseUrl
}),
);
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
Answers
A set formatter is the correct way to do it. Use
$data['fullurl']
to get thefullurl
value that was suggested from the client-side (rather than$value
since you aren't submitting a baseurl).Allan
Thanks Allan!