Drupal Flag Module Checkbox Solution

By

Web users are accustomed to clicking on checkboxes, buttons, and icons to flag and unflag items of all sorts, such as favorite blog posts. The Flag module is a popular project for implementing flag capabilities on Drupal websites. Thus, it is a shame that it does not support checkboxes or any other intuitive interface elements on entity displays, but instead uses only links (as of this writing).

Fortunately, there is at least one workaround, which would be implemented on the flag admin page for the given entity type, such as nodes (admin/structure/flags/manage/node_flag): You can use characters that look like unchecked and checked checkboxes (☐ and ☑), instead of or as part of the "Flag link text" and "Unflag link text" values, respectively. These special characters are the Unicode characters U+2610 ("ballot box") and U+2611 ("ballot box with check"), and can be displayed on web pages using the HTML decimal entities "☐" (hex "☐") and "&amp#9745;" (hex "☑").

Beware that, if these characters are used alone, with no accompanying explanatory text and no helpful title attribute in each anchor's open tag, then this approach produces HTML that may not be accessible by assistive browsing technologies. But for now, it may have to do.

Copyright © 2014 Michael J. Ross. All rights reserved.