October CMS resources and help articles

Simple and to the point. Optimized by the community.

Prefill relation widget from main form

by Johanness, last modified on November 14th, 2022

To prefill a relationform, we can use the relationManageWidget function in our controller. Conveniently the relationmanagerAjaxCall POSTs the current (not yet saved) form data of the calling form. So we can prefill the popup form like this:

    public function relationExtendManageWidget($widget, $field, $model)
                        if($field === 'comments'
                                && property_exists($widget->config, 'context')
                                && $widget->config->context === 'create'
                        ) {
                                if ($post){
                                        $widget->model->title = 're: '.$post['title'];



We use cookies to measure the performance of this website. Do you want to accept these cookies?