Homepage
Main navigation
Main content
Additional information
October Tricks
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
October CMS resources and help articles
Simple and to the point. Optimized by the community.
×
Login / Sign up
Quality Guidelines
About
GitHub
Propose new content
Edit trick
Changes will be published after manual review
Title
Give your trick a describing title. Do
not
start with «How to...».
Your trick
Keep it short and concise! Markdown is supported.
Refreshing a backend form on save can be done if you modify the `_post_toolbar.htm` partial to include `refresh:1` as mentioned below. Create a new file called `_post_toolbar.htm` with the contents below and place it in the `partials` folder of your own plugin. <?php $isCreate = $this->formGetContext() == 'create'; $pageUrl = isset($pageUrl) ? $pageUrl : null; ?> <div class="form-buttons loading-indicator-container"> <!-- Save --> <a href="nojavascript...;" class="btn btn-primary oc-icon-check save" data-request="onSave" data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>" data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" <?php if (!$isCreate): ?>data-request-data="refresh:1"<?php endif ?> data-hotkey="ctrl+s, cmd+s"> <?= e(trans('backend::lang.form.save')) ?> </a> <?php if (!$isCreate): ?> <!-- Save and Close --> <a href="nojavascript...;" class="btn btn-primary oc-icon-check save" data-request-before-update="$el.trigger('unchange.oc.changeMonitor')" data-request="onSave" data-load-indicator="<?= e(trans('backend::lang.form.saving')) ?>"> <?= e(trans('backend::lang.form.save_and_close')) ?> </a> <?php endif ?> <!-- Preview --> <a href="<?= URL::to($pageUrl) ?>" target="_blank" class="btn btn-primary oc-icon-crosshairs <?php if (!false): ?>hide<?php endif ?>" data-control="preview-button"> <?= e(trans('backend::lang.form.preview_title')) ?> </a> <?php if (!$isCreate): ?> <!-- Delete --> <button type="button" class="btn btn-default empty oc-icon-trash-o" data-request="onDelete" data-request-confirm="<?= e(trans('rainlab.blog::lang.post.delete_confirm')) ?>" data-control="delete-button"></button> <?php endif ?> </div> Then, in your plugins own Plugin.php file, add the following code in the `boot()` method: \Event::listen('backend.form.extendFieldsBefore', function ($widget) { if (!($widget->getController() instanceof \RainLab\Blog\Controllers\Posts && $widget->model instanceof \RainLab\Blog\Models\Post)) { return; } $widget->fields['toolbar']['path'] = '$/author/plugin/partials/_post_toolbar.htm'; }); After saving your form, the page should refresh and display the right values if you modified something with a `beforeSave event`. Credits to @mjauvin and @lucas.sanner54070 for suggesting this in the October CMS forums, with the above example of the Rainlab Blog plugin:
References
Add additional online resources to your trick
×
Name
URL
+ Add reference
Topics
If your trick fits more than one topic select multiple. Select at least one.
Backend
Plugin Development
CMS
Twig
Themes
Deployment
Tags
You can use existing tags or create new ones. Add at least one.
Submit for review
Cancel
We use cookies to measure the performance of this website. Do you want to accept these cookies?
Accept
Decline