Prefill relation widget from main form
1
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'
) {
$post=Input::get('post');
if ($post){
$widget->model->title = 're: '.$post['title'];
}
}
}
There are no comments yet
Be the first one to comment