This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I need to slighly modify the checkboxes in the categories tab of my item.
The original checkbox list partial lives here:
modules/backend/widgets/form/partials/_field_checkboxlist.htm
so I copied it into my plugin directory:
plugins/companyname/pluginname/models/item/_field_checkboxlist.htm
Now in my item field.yaml I added the path to the partial to extend.
categories:
type: relation
path: ~/plugins/companyname/pluginname/models/item/_field_checkboxlist.htm
but the path is not taken into account. Conversely, if I change the field type
categories:
type: partial
path: ~/plugins/companyname/pluginname/models/item/_field_checkboxlist.htm
the path is now taken into account but the category data is no longer available.
Is there a (easy) way to extend this partial without rewriting everything ?
Just add this to your controller:
public function formExtendFieldsBefore($widget)
{
$widget->addViewPath([ '$/companyname/pluginname/models/item' ]);
}
Last updated
Nope, it doesn't work.
However I found out in which file the path should be modified:
modules/backend/formwidgets/relation/partials/_partial.htm
<div class="relation-widget" id="<?= $this->getId() ?>">
<?= $this->makePartial('~/modules/backend/widgets/form/partials/_field_'.$field->type.'.htm', ['field' => $field]) ?>
</div>
Of course I cannot hardcode a native file.
So would you have any idea about how to extend this file ?
It works fine, I tried it.
which field type are you trying to customize? Care to show the actual code you used in your controller?
If you're trying to modify the Relation formwidget, this is totally different. Use this in your plugin's boot method:
\Backend\FormWidgets\Relation::extend(function ($widget) {
$widget->addViewPath([ '$/companyname/pluginname/models/item' ]);
});
And copy the file modules/backend/formwidgets/relation/partials/_relation.htm
to your companyname/pluginname/models/item
folder and adapt to your needs
Last updated
which field type are you trying to customize?
A relation type field.
The field data is computed through the makeRenderFormField() method in this file:
modules/backend/formwidgets/Relation.php
then rendered in this file:
modules/backend/formwidgets/relation/partials/_partial.htm
It's actually rendered in modules/backend/formwidgets/relation/partials/_relation.htm
Please see my previous post above, that should solve your problem
1-8 of 8