Now that we have #1445224: Add new HTML5 FAPI element: color landed for FAPI, we should really add the ability to have a color field type. It should probably have one column 'color' of type SQL varchar(7), and a field widget using the new HTML5 FAPI type, and a default formatter of just 'plain text' that outputs the raw value.

Based on #1675000: Allow selecting an alpha channel for the color FAPI element we may add support for an 'alpha' column via a field setting (since it changes the field schema).

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Issue tags: +html5
larowlan’s picture

Status: Active » Needs review
Issue tags: +Needs tests
FileSize
4.72 KB

First go

plopesc’s picture

Issue tags: -Needs tests
FileSize
6.01 KB

Hello

After #1668332: Add an E-mail field type into core, providing a patch where the field architecture is based in a separate submodule.

Tests has been included in this approach.

Regards

moshe weitzman’s picture

I think we should have a use case before adding it, or else it stays in Contrib. Add 'Favorite color' to the User entity? :)

swentel’s picture

Version: 8.x-dev » 9.x-dev

Yeah, I guess this is D9 material

catch’s picture

Version: 9.x-dev » 8.1.x-dev
Issue summary: View changes
JurriaanRoelofs’s picture

As a theme/site-builder tool developer I can think of use cases for this. color fields would be nice to implement per-node, per-context, per-role etc. design variations to theme regions or dynamic content.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Pere Orga’s picture

I think we should have a use case before adding it, or else it stays in Contrib. Add 'Favorite color' to the User entity? :)

The module on its own would not be very useful. But whether it is in core or in contrib, it would allow to build solutions such as the ones described in #7. The only advantage I see of having it in core would be that contrib modules and themes would be able to use it immediately. Maybe that's why the color element was added to Form API.

There are at least 3 different modules that provide a color field type:
https://www.drupal.org/project/jquery_colorpicker (7.x, 8.x)
https://www.drupal.org/project/color_field (7.x, 8.x)
https://www.drupal.org/project/colorfield (only 7.x for now)

Unfortunately all of them are more complex, add more stuff and/or require using external libraries. Ideally, if these modules needed to exist they should be extending the Form API/field core's functionality.

About adding it as a contrib project: @larowlan @plopesc have you considered creating the project? I could also create it, as I need this functionality right now and I was thinking to use it for future 8.x versions of https://www.drupal.org/project/field_group_background_image. By the way, I see that the name "color_field" is already in use by the existing Color Field contrib module (and has 8.x releases...)

plopesc’s picture

Hi Pere,

That'd be great and I would be happy to help with that, but as you pointed we now have the namespace issue. We cold use "rgb_field" as less bad option.

Other option would be to try to contact with color_field/colorfield maintainer and ask them to create new branches to use as color API module and then create multiple submodules adding extra features or using external libraries.

Pere Orga’s picture

Hi,

Other option would be to try to contact with color_field/colorfield maintainer and ask them to create new branches to use as color API module and then create multiple submodules adding extra features or using external libraries.

Even if that may be possible, I was wondering if having this new module as a separate project would be a better option. Nowadays all major browsers support input type color; if a polyfill is desired to add support for older browsers, that polyfill should work for all form fields, not just Field API fields, and therefore it would make sense to have it as an external project. That way the polyfill could be used for a broader audience.

Adding external libraries would harden maintenance, and that would favor only one or a few libraries, not necessarily the best ones.

By the way rgb_field name sounds acceptable to me.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Pere Orga’s picture

FWIW, I see that now there is Color API contrib module (used by Jquery Colorpicker), and that Color Field also gained input type=color support.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
FileSize
9.29 KB

The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

catch’s picture

Project: Drupal core » Drupal core ideas
Version: 10.1.x-dev »
Component: field system » Idea

There are about 30,000 Drupal 8+ sites using https://www.drupal.org/project/color_field, which is a fair amount, but I'm not sure it's enough to justify adding the field type to core. We're already considering moving telephone to contrib since that isn't widely used. Moving this to the core ideas queue for new feature evaluation.