Backend List Inline Editor

I try to build an inline editor for a backend list, so the entries can directly be edited from the list without the need to go to the update-area of a model.

I’ve build up several inline buttons with handlers already:

            data-request-data="checked[]: <?= $record->id ?>"

Works great so far.

The bigger issue however is, the update of some text fields like a name field.

Therefor, I have a text input field in another partial of the list entry and I would like to send the actual value of this input to the handler.

My first approach was “data-track-input”, but since I dont want to tigger the handler directly with a change on the input field, this is no option.

The second approach was “data-request-form”, but I couldnt get this to work. This is the form in the first partial:

<form name="formname_<?= $record->id ?>">
    <input id="name_<?= $record->id; ?>" value="<?= $firstName ?>">

And this here the button:

            class="btn btn-default btn-sm oc-icon-check-square-o empty mb-1"
            data-request-form="formname_<?= $record->id ?>"
            data-request-data="checked[]: <?= $record->id ?>"

I tried to get the values with Input::get() but only the checked[] entry was inside the array.

Update of the data-request-data with JS
The third approach was an update of the data-request-data with JS as mentioned in the first post of this thread, but also didnt have success here. The thread suggests the first two solutions anyways. I also tried to grad the values with the post() method, but no luck.

Best solution would be the second approach with the additional form, so I hope to get some tipps on what I missed here. Thanks a lot ^^

This plugin gives a good example of inline list editing:

1 Like

Thanks a lot, but the List Switch wont help with the input field thing :wink:

However, it still brought me to the solution… in the one or other way:

So: If you would like to create an inputfield in a Backend List and Save the value on Enter, here’s the way to go:

    <form data-request="onEditName" data-request-data="checked[]:<?= $record->id ?>">
        <input name="name" value="<?= $inputValue; ?>">
        <button type="submit" hidden></button>

Sends the record ID and the given input field value to the handler if you press Enter.

Hope this helps someone one day

BUT: There’s still one issue left:

When I type a “space” in this input field, the record opens. How can I stop this from happening?