The “Pages” model in the form has a group repeater “content” which has a field “doctors” - how to extend “doctors”?
use KonvertAgency\Landing\Controllers\Pages as PagesController;
PagesController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'content[doctors]' => [
'label' => 'test',
'tab' => 'new tab',
]
]);
});
What should I write instead of 'content[doctors]'
?
(field “content” is jsonable)
daft
September 28, 2023, 2:25am
#2
It depends on the structure, but perhaps something like this.
$form->getField('content')['form']['fields']['doctors'] = [
'label' => 'test',
'tab' => 'new tab',
]
This does not work. Perhaps I did not accurately describe the problem.
public function register() {
\Event::listen('backend.form.extendFields', function ($widget, $form) {
if ($widget->getController() instanceof \Konvertagency\Landing\Controllers\Pages) {
if ($widget->model instanceof \Konvertagency\Landing\Models\Page) {
foreach ($widget->model->content as $item) {
if (array_key_exists("_group", $item) && $item["_group"] === "doctors") {
// dd($form);
$widget->addTabFields([
'test' => [
'label' => 'test',
'tab' => 'new tab',
],
]);
}
}
}
}
});
}
dd($form);
in display
The “content” field is a group repeater. I need to extend one of its elements, which is named “doctors”.
In the presented code, the “new tab” tab is inserted into a general form, but it is only needed in the group repeater element called “doctors”.
daft
September 29, 2023, 10:40pm
#4
Try this event instead:
Event::listen('system.extendConfigFile', function ((string) $path, (array) $config) {
if ($path === '/plugins/author/plugin-name/controllers/mycontroller/config_relation.yaml') {
unset($config['property_value']['view']['recordUrl']);
return $config;
}
});
1 Like
Yes! This is what i need.
it works
public function boot()
{
\Event::listen('system.extendConfigFile', function ($file, $config) {
if ($file == "/plugins/konvertagency/landing/models/page/listcontent.yaml") {
$config['doctors']['fields'] += ['mousetracking' => [
'tab' => 'konvertagency.mousetrackingphoto::lang.plugin.name',
'label' => 'konvertagency.mousetrackingphoto::lang.plugin.name',
'type' => 'switch',
'span' => 'left',
'default' => '0',
'trigger' => [
'action' => 'show',
'field' => 'type_card',
'condition' => 'value[0]',
]]];
// dd('boot',$file, $config);
return $config;
}
});
}