- ๐ช๐ธSpain rodrigoaguilera Barcelona
I implemented something similar to #4 that works for select list fields by triggering the submit when the input changes. Maybe the event, "change" in this case, should be configurable.
I tried to attach an #ajax callback to the select field in the render array but that didn't add any event to the
element.Attached is a patch against 1.0.1.
- ๐ช๐ธSpain rodrigoaguilera Barcelona
Attached is an improved version that allows for changing the event that is triggered.
- ๐บ๐ฆUkraine gilmord ๐บ๐ฆUkraine
Hi @rodrigoaguilera can you please create a fork and open a merge request based on your patch?
Thanks! - Merge request !13Issue #3253634 by rodrigoaguilera, gilmord: Autosave option for editable node fields โ (Merged) created by rodrigoaguilera
- ๐ช๐ธSpain rodrigoaguilera Barcelona
-
gilmord โ
committed d789113a on 1.0.x authored by
rodrigoaguilera โ
Issue #3253634 by rodrigoaguilera, gilmord: Autosave option for editable...
-
gilmord โ
committed d789113a on 1.0.x authored by
rodrigoaguilera โ
- ๐บ๐ฆUkraine gilmord ๐บ๐ฆUkraine
This is far from perfect, but at least something
It works for the simple cases, and should be a good starting pointThanks!
- Status changed to Fixed
11 months ago 4:26pm 30 January 2024 It looks like this feature was committed, but I'm at a loss as to how to use it.
I see that two new fields appear in the views field settings:
- Fields that trigger an ajax submit when they change (autosave)
- Event that will trigger an ajax submit for the fields above
Adding anything at all to the first field causes the update button to hide, but I can't get the field itself to update. What is the correct syntax?
Does something else need to be configured, or is there an additional missing patch? Should the view's Ajax be on or off? Some direction would be appreciated.
- ๐น๐ญThailand AlfTheCat
@tonka67 It seem like autosave is not working in views. Best result I can get is to use ajax in the view and hit tab and then enter, after typing a value in the editbale field. This updates the field. I tried "blur" and "change".
If autosave for views is broken then a new issue should be opened as this one is closed and maybe only targeted nodes/entities.
- ๐บ๐ฆUkraine gilmord ๐บ๐ฆUkraine
Views field configuration:
Result:
The "Fields that trigger ajax" - this is array keys of the widget form, you can check here how it is used:
https://git.drupalcode.org/project/editablefields/-/merge_requests/13/di...And the "Event that will trigger an ajax" - is a javascript event to be bind to trigger submit
@tonka67 a few things to check:
- make sure you use the latest dev version of the module
- use Inspect Element in browser developers tools and check the event is attached to the field in the view
- if the event IS there and does not work - check the javascript console output, maybe there are some errors
- if the event IS NOT attached - please use xdebug or any other way to debug the inside of "foreach ($fields_ajax as $field_ajax) {" loop to check if the value you set in "Fields that trigger ajax" is in the $formOne more thing - for the cases when the entire view is wrapped in a form element (for example if you use Views Bulk Operations) you have to set the "Select behavior" of the field to "Form in popup" instead of the default "Inline form"
- ๐น๐ญThailand AlfTheCat
@gilmord thank you very much for the guidance, I now managed to get it working. I was using {{ title }} and when that didn't work, I tried [title]. Using title made it work.
Perhaps out of scope, but is there a way to also ajax-refresh the view so that totals and other, non-editable field values update as well? In my case, I have a view of line items that have an editable quantity field, and non-editable line item total fields and then there is a sub-total aggregated value as well.
@gilmord it took me longer than expected to loop back around to this.
On testing I can get the Title field to work perfectly, but the body field, which has a ckeditor attached to it, does not register the ajax at all.
Are long, formatted text fields set up differently?