Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 297680

Selected yet disabled individual options from checkboxes widget don't persist through save

$
0
0

Problem/Motivation

It is possible to programatically disable individual options on a checkboxes widget with the intention to show the selected value to users but disallow deselection, but if you do so the previously stored value will be removed despite having been show to the user as selected.

This is split out from #2911473: Selected yet disabled individual options from checkboxes element don't persist through save which addresses this more generally at the FAPI level and should be fixed first.

Steps to reproduce

  1. Add a field to article, as follows:
  • Field type: boolean
  • Field label: My Field
  • Save and continue
  • Set number of values to unlimited
  • Save field settings
  • Leave all settings, and click Save settings
  • Configure the Manage form display to use the widget "Checkboxes/radio buttons".
  • Add this line of code as the last line in book_form_node_form_alter
  • $form['field_my_field']['widget'][0]['#disabled'] = TRUE;
  • Enable the book module
  • Add an article, view the form -- see that the first option is disabled but selected
  • Submit the node form.
  • Edit the new article node -- see that the first option is disabled but NOT selected
  • Proposed resolution

    To be determined.

    Remaining tasks

    Diagnose.
    Fix.
    Add test.

    User interface changes

    None.

    API changes

    None.

    Data model changes

    None.


    Viewing all articles
    Browse latest Browse all 297680

    Trending Articles



    <script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>