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

Command icon 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

nuez created an issue. See original summary.

gilmord’s picture

Hi @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.

nuez’s picture

There 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.

gilmord’s picture

Hi @nuez

added a few fixes to the MR, please check

nuez’s picture

Status: Active » Needs review
nuez’s picture

I 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.

gilmord’s picture

Status: Needs review » Postponed (maintainer needs more info)

@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?

nuez’s picture

I'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.

gilmord’s picture

Status: Postponed (maintainer needs more info) » Fixed

Hi @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!

nuez’s picture

great!

nuez’s picture

Not 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?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

gilmord’s picture