Problem/Motivation
Instead of showing the editing form for each field immediately, I would like to render the field with a regular field formatter with an 'edit' button. When clicking the edit button, the field widget appears.
Proposed resolution
- Add the possibility to add a 'edit' toggle button in the formatter settings and a corresponding fallback view mode.
- Alter the EditableFieldsForm so that it renders the fields and widgets with corresponding toggle buttons.
Remaining tasks
Write tests
Data model changes
Issue fork editablefields-3265850
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
gilmordHi @nuez
thanks for your efforts!
I am not sure about the usage of ajax to toggle view/edit.
The entire request to the back-end looks redundant if we just want to show/hide a small piece of content.
Can be achieved with a simple js snippet, maybe we should consider this solution.
In general, MR looks good, I will check it and merge once tested.
Comment #4
nuezThere is indeed the option of hiding / showing the form with a javascript snipped. I have considered it, but haven't tried it.
I chose to use AJAX, because I thought pure JS might lead to issues with the validation of the form.
Besides, assuming that actually editing the field is a rare occurrence, it feels equally redundant to always render the form when we only rarely need it.
I deliberately tried to separate the new functionality from the old in order mess up the existing code but I think it could be a lot better integrated.
I'm still bumping into an issue locally which I will try to solve.
Comment #5
gilmordHi @nuez
added a few fixes to the MR, please check
Comment #6
nuezComment #7
nuezI think that now we show the rendered field, if the field is empty, there is no information whatsoever. I think we should also provide an 'empty' message to be displayed when the field is empty to begin with.
Comment #8
gilmord@nuez I see you set the issue for the review, but then added a couple of commits.
What is the current status?
Is it ready for review?
Comment #9
nuezI've been using this functionality and for now haven't bumped into mayor issues. But I haven't tested it with all possible use cases, nor have I implemented tests. I you want to review it, please do. I'm not sure when I will have time to continue to work on this.
Comment #13
gilmordHi @nuez
created a new MR, a lot of things based on your implementation but contains a couple of extra features and naming conventions.
Please check it, it is merged in the dev branch 1.0.x
Thanks for your work, granted you a credit!
Comment #14
nuezgreat!
Comment #15
nuezNot sure how the new branch works, the configuration in my old branch seems to be gone in the new branch and I can't seem to configure it in the same way with the new branch. Can you explain how they compare?
Comment #17
gilmordHi @nuez
Please check instructions here:
https://git.drupalcode.org/project/editablefields/-/blob/1.0.x/README.md