This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

OFFLINE
OFFLINE

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

Jiri Kubak
Jiri Kubak

I have same problem and i can't fix it :/

same for methods: relationRender and relationRefresh

Last updated

Jiri Kubak
Jiri Kubak

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

OFFLINE
OFFLINE
// 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:

https://github.com/octobercms/october/issues/1752

RomaldyMinaya
RomaldyMinaya

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

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.