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've got a custom relation toolbar button that makes a call to onRelationButtonApprove
:
<button onclick="$(this).data('request-data', {
checked: $('#longSelector').listWidget('getChecked')
})" data-request="onRelationButtonApprove">
Approve selected
</button>
In my controller action I return
public function update_onRelationButtonApprove()
{
// ... set approved = 1 on selected entries
return $this->relationRefresh('bookings');
}
Unfortunately, this returns the following error: Relation behavior used in :class does not have a model defined.
The built-in onRelationButtonDelete
works like a carm.
How do I use relationRefresh
correctly?
Thanks.
Last updated
I have same problem and i can't fix it :/
same for methods: relationRender and relationRefresh
Last updated
I find some solution so: i have enquiry = model and model $hasMany orders
Button - i have button for each row - order
<button
class="btn btn-sm btn-primary oc-icon-reply-all"
data-request="onSendEmailFitter"
data-request-data="child_id: <?= $record->id?>, model_id: <?= $this->formGetModel()->id ?>"
data-request-confirm="Are you sure?"
data-trigger-condition="checked" data-stripe-load-indicator=""
>
Send to Fitter
</button>
And controller with relation refresh
public function onSendEmailFitter() {
$child_id = post("child_id");
$model_id = post("model_id");
// change child - order
$order = \WPS\Application\Models\Order::find($child_id);
if ($order!= null) {
$order->sendOrderToFitter();
}
Flash::success('Email sent successfully.');
// October BUGs - init again
$model = Enquiry::find($model_id);
$this->initForm($model);
$this->initRelation($model,"orders");
// return refresh
return $this->relationRefresh("orders");
}
Last updated
// October BUGs - init again
$model = Enquiry::find($model_id);
$this->initForm($model);
$this->initRelation($model,"orders");
... fixed the problem! Thank you. I have reported this as a bug:
Jiri Kubak said:
I find some solution so: i have enquiry = model and model $hasMany orders
Button - i have button for each row - order
<button class="btn btn-sm btn-primary oc-icon-reply-all" data-request="onSendEmailFitter" data-request-data="child_id: <?= $record->id?>, model_id: <?= $this->formGetModel()->id ?>" data-request-confirm="Are you sure?" data-trigger-condition="checked" data-stripe-load-indicator="" > Send to Fitter </button>
And controller with relation refresh
public function onSendEmailFitter() { $child_id = post("child_id"); $model_id = post("model_id"); // change child - order $order = \WPS\Application\Models\Order::find($child_id); if ($order!= null) { $order->sendOrderToFitter(); } Flash::success('Email sent successfully.'); // October BUGs - init again $model = Enquiry::find($model_id); $this->initForm($model); $this->initRelation($model,"orders"); // return refresh return $this->relationRefresh("orders"); }
Thank you my brother T.T
1-5 of 5