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

amorphine
amorphine

I suppose you get what I mean by 'Manage step': after linking another Model we can enter additional data for pivot table.

I try to be able to get from a server some values for pivot data after linking a related record to the main one. Here's a step of entering pivot data and some of them should be generated (no problem to enter them manually, the problem is to make it through AJAX with a single click on Synchronize button):

Here's full page I have https://goo.gl/ntxjaD

And this is a manage step after adding Sight to Route: https://goo.gl/BwYPZ8 Here's an example of related fields.yaml

fields:
    pivot[sort]:
        label: Order
        type: number
        span: auto
    pivot[time_from_start_to_sight]:
        label: Time from start to the sight
        type: number
        span: auto
    pivot[add_route_time]:
        label: Add time
        type: number
        span: auto
    pivot[add_route_price]:
        label: Basic add. price
        type: number
        span: auto
    pivot[stay_time_default]:
        label: Default stay time
        type: number
        span: auto
    pivot[stay_time_min]:
        label: Min. stay time
        type: number
        span: auto
    pivot[stay_price]:
        label: Price per quarter of hour
        type: number
        span: auto
    _gmaps_sync:
        label: You may try to get data from Google Maps API
        type: gmapsroutesightsync
        commentAbove: Make sure you have entered Google Maps API key

As you can see I added a custom widget to be able to paint a button. I can even call an AJAX-handler of a widget and apply new values to the passed data saving them to DB inside the controller.

The custom widget partial:

<?php if ($this->previewMode): ?>

    <div class="form-control">
        <?= $value ?>
    </div>

<?php else: ?>

<button data-request="onGMapsSync" type="button" class="btn btn-info">Synchronize</button>

<?php endif ?>

But I do not have the slightest idea how to push updated partial or update the partial with new values. Of course it's possible update every field by 'custom' JS code - but I'm sure there's a smart way.

Please point to the best practices. Thank you.

Last updated

1-1 of 1

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