This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
Hi, I'm pretty new to laravel / october cms and I'm interested in if there is possibility to extend recordfinder with ability to create new items on the flow, as it's implemeted in cases when we have hasMany relations and use Relation Behaviour / relationRender? Or maybe at least someone can point me on how to reproduce recordfinder in my partial type form field?
Thanks!
So my solution was modifying "_recordfinder.htm" found in "/modules/backend/formwidgets/recordfinder/partials" by adding following code
<!-- Create new item button -->
<div class="form-group" data-field-name="<?= $this->fieldName; ?>" style="padding-bottom:0px;">
<div data-request-data="_relation_field: '<?= $this->fieldName; ?>'">
<a data-control="popup" data-size="huge" data-handler="onRelationButtonCreate" href="nojavascript...;" class="btn btn-sm btn-primary oc-icon-plus" style="right:20px; top:11px;">
</a>
</div>
</div>
<!-- Create new item button -->
right after line containing: <?php if (!$this->previewMode): ?>
Hope this will be useful for someone.
Last updated
Actually, I've found a method to add view paths to individual form field widgets (formwidget) on the fly:
In this example, we add the partial path "plugins/vendor/plugin/controllers/myclass/myformfield" to the widget, which is responsible for the field "myformfield".
class MyClass extends Controller
{
public $implement = [
'Backend.Behaviors.FormController',
];
public $formConfig = 'config_form.yaml';
public function create()
{
$form = $this->asExtension('FormController')->create();
// add a new partial view path for a single form field
$companyFieldWidget = $this->asExtension('FormController')->formGetWidget()->getFormWidget('myformfield');
$companyFieldWidget->addViewPath('$/vendor/plugin/controllers/myclass/myformfield');
//
return $form;
}
So the first time I used this method it worked... however now I am getting an error:
'The partial _manage.htm' is not found.
Any ideas?
One option is to copy all needed partials into the new (changed) folder.
Another option is to explicitly set the path of the partial inside the template. If you don't do that, October will search for a file in the same directory your template is located in. And since you have changed it with this line - $companyFieldWidget->addViewPath('/plugins/vendor/plugin/...')
- your default directory to search for partials has changed.
1-7 of 7