Problem/Motivation

In scenarios where the entity has been populated and the data for a field is presented read-only in the form, it could be useful to allow for configurable empty text on the widget configuration.

In an example scenario, we are populating entities through Migrate. Those entities will then be reviewed in edit mode, where some data is allowed to be modified directly, and in other cases we display the migrated data as read-only and ask the person reviewing the entity if that data is correct. In instances where no data was migrated for a field it would be useful to display a message such as "This field is empty." or "No data present", etc.

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

jerdavis created an issue. See original summary.

thtas’s picture

Perhaps this will work in conjunction with the https://www.drupal.org/project/empty_fields module?

jerdavis’s picture

Empty Fields works on field formatters, not field widgets. Just as I need this module to render the field widget (input) as read-only, I need it to also have functionality to display a message when that field is empty. The field formatter renders the output of the field on the view of an entity, rather than the form mode.

thtas’s picture

This module uses the field formatters as options to display in the widget mode, so I was hoping the empty field module options might be available without too many changes to this module, but it sounds like it might need some integration work.

thtas’s picture

StatusFileSize
new7.83 KB

In order for this module to work with the Empty Fields module, it first needs support for field formatter third party settings.

Attached is a patch to bring in such support in a general way.

However, because of the way the Empty Fields AJAX forms make assumptions about the structure form state it will need patches or perhaps some other workaround before it will work with this module.

Todo:
- Add some test coverage to ensure that third party settings work as expected in a simple example (partially done)
- Investigate patching Empty Fields so that their third party settings ajax forms work with the patch attached here.

thtas’s picture

Title: Support an empty text option in widget formatter » Support for Empty Fields and other third party formatter settings.
pookmish’s picture

StatusFileSize
new7.59 KB

Re-rolling patch from #6 for latest 1.6.0 version. I'll create a MR as well.

pookmish changed the visibility of the branch 3220671-empty-text to hidden.

pookmish changed the visibility of the branch 8.x-1.x to hidden.

rigoucr’s picture

Version: 8.x-1.x-dev » 2.x-dev
StatusFileSize
new2.38 KB

patch reroll for version 2.x
I made a mistake and provide the wrong patch

rigoucr’s picture

rigoucr’s picture

Now providing the right patch reroll for the MR 1, sorry about the other one.

astonvictor’s picture

Version: 2.x-dev » 2.1.x-dev

astonvictor’s picture

Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

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