Sandbox project available at Doublefield Formatter

This provides a more versatile "expert mode" formatter for the useful Double Field module, giving precise control over HTML tags and attributes. Double field is very good for presenting information as pairs of terms and definitions, e.g. technical specifications, where you do not know how many attributes you wish to describe. Using Display Suite Extras or Fences you can control the HTML around the field items, but have to rely on one the default formatters for the inner HTML or write custom theme function in your theme's template.php file. This module removes the need for a theme function in template.php or custom templates.

Inspiration

The Double Field module fulfils an essential requirement for many projects, enabling editors to enter miscellaneous content in pairs of terms and descriptions, e.g. for details, attributes or specifications. Although Double Field itself comes with a set of formatters, none gives the administrator full control over the rendered HTML, especially when seeking to comply with strict requirements for design, search engine optimisation, semantic markup and accessibility. The module only requires Double Field, but is ideally used with Display Suite and Display Suite Extras or Fences allowing full control over field templates. Also implemented are all options available in the default formatter for this field type.

How it differs from other modules

Double Field is a rather niche module, though well maintained for a discerning audience and I could not find another module that provide a custom formatter for it. In earlier projects, e.g. at http://www.london.ac.uk, I had implemented a theme hook to meet requirements. However, this can become unmaintainable as requirements and designs evolve. Administrators just want a simple tool to customise markup without asking a developer to edit a php file.

Standards

The module implements documented field hooks and where practical places detailed implementation in a separate file to minimise load when the formatter is not used.

CommentFileSizeAuthor
doublefield_formatter-7.1.tgz4.31 KBNeil Gardner

Comments

Neil Gardner’s picture

Issue summary: View changes
PA robot’s picture

Status: Needs review » Needs work

Git clone failed for http://git.drupal.org/sandbox/neilgardner/2391763.git while invoking http://pareview.sh/pareview/httpgitdrupalorgsandboxneilgardner2391763git

Git repository is empty. Aborting.

We are currently quite busy with all the project applications and we prefer projects with a review bonus. Please help reviewing and put yourself on the high priority list, then we will take a look at your project right away :-)

Also, you should get your friends, colleagues or other community members involved to review this application. Let them go through the review checklist and post a comment that sets this issue to "needs work" (they found some problems with the project) or "reviewed & tested by the community" (they found no major flaws).

I'm a robot and this is an automated message from Project Applications Scraper.

joachim’s picture

Is there now code in the repo? Please set this back to 'Needs review' when there is so the bot notices and tries again. Also, note that the issue summary should give the git clone command for the convenience of human reviewers.

BTW, please don't add random keywords to the issue tags -- read the issue tag guidelines that are mentioned in the field help text.

joachim’s picture

Issue tags: +#security

Manual Review

Individual user account
Follows the guidelines for individual user accounts.
No duplication
Does not cause module duplication and/or fragmentation There are several modules that cover the compound field space: https://www.drupal.org/project/multifield, https://www.drupal.org/project/field_collection, https://www.drupal.org/project/composed_field, and https://www.drupal.org/project/double_field itself -- however that this module extends one of those isn't a problem.
Master Branch
Follows the guidelines for master branch.
Licensing
Follows the licensing requirements.
3rd party assets/code
Follows the guidelines for 3rd party assets/code.
README.txt/README.md
Does not follow the guidelines for in-project documentation and/or the README Template. The README text needs to be wrapped to 80 characters.
Code long/complex enough for review
Follows the guidelines for project length and complexity.
Secure code
Does not meet the security requirements:
  • (*) None of the 3 tag fields in the field formatter settings form have their values escaped when presented to the user in the settings summary. For example, I can enter "<script>alert('bananas')</script>"
  • (*) None of the 3 tag fields or suffix or prefix fields in the field formatter settings form have their values escaped when presented to the user in the rendered field.
Coding style & Drupal API usage
  1. (*) _doublefield_formatter_field_formatter_settings_form(): documentation for this function is incorrect:
    1. it's not actually a hook implementation, since it does not start with the name of the module
    2. docblock is not correctly formatted
    3. parameters are not correctly formatted and missing descriptions
  2. (*) When I save the field formatter settings I get: "Notice: Undefined variable: var_name"
  3. (*) The 'wrapper tag' field either does not save, or the form element is not populated with the existing value.
  4. (*) Viewing a node with the formatter set up produces "Undefined variable: strAttrs"
  5. (+) version = "7.x-1.0" -- do not put the version number in; this is added automatically by d.org packaging
  6. (*) t(ucwords($type) . ' item tag') -- incorrect use of t().
  7. (*) '#title' => ucwords($type) . ' sub-field ' -- missing t()
  8. Implements hook_field_formatter_info() -- needs a full stop (other hooks similar).
  9. $firstSettings -- drupal code standards use camel_case for function variables.
  10. 'second' => $secondSettings -- code standards, missing final comma
  11. missing newline at the end of the code files
  12. there's no need for a .install file if it's empty
  13. doublefield_formatter_field_formatter_info() -- indentation in this function is wrong
  14. } else { -- don't coddle elses
  15. _doublefield_formatter_build_classes -- pretty sure core has a function for that. Try drupal_attributes() or something similar.

The starred items (*) are fairly big issues and warrant going back to Needs Work. Items marked with a plus sign (+) are important and should be addressed before a stable project release. The rest of the comments in the code walkthrough are recommendations.

If added, please don't remove the security tag, we keep that for statistics and to show examples of security problems.

This review uses the Project Application Review Template.

klausi’s picture

Issue tags: -#security +PAreview: security

We use "PAReview: security" to indicate security issues in sandbox project applications.

PA robot’s picture

Status: Needs work » Closed (duplicate)
Multiple Applications
It appears that there have been multiple project applications opened under your username:

Project 1: https://www.drupal.org/node/2392699

Project 2: https://www.drupal.org/node/2392703

As successful completion of the project application process results in the applicant being granted the 'Create Full Projects' permission, there is no need to take multiple applications through the process. Once the first application has been successfully approved, then the applicant can promote other projects without review. Because of this, posting multiple applications is not necessary, and results in additional workload for reviewers ... which in turn results in longer wait times for everyone in the queue. With this in mind, your secondary applications have been marked as 'closed(duplicate)', with only one application left open (chosen at random).

If you prefer that we proceed through this review process with a different application than the one which was left open, then feel free to close the 'open' application as a duplicate, and re-open one of the project applications which had been closed.

I'm a robot and this is an automated message from Project Applications Scraper.

chi’s picture

Status: Closed (duplicate) » Needs work

It appears that there have been multiple project applications opened under your username:

This one already has manual review.

PA robot’s picture

Status: Needs work » Closed (won't fix)

Closing due to lack of activity. If you are still working on this application, you should fix all known problems and then set the status to "Needs review". (See also the project application workflow).

I'm a robot and this is an automated message from Project Applications Scraper.

lazzyvn’s picture

Hello
how can i use hook_field_widget_WIDGET_TYPE_form_alter for double field?
is there hook_field_widget_double_field_form_alter?
why type double_field_field_widget_info() return $widgets[$first_subwidget . '_&_' . $second_subwidget]
that means we can not use hook field_widget_textfield_&_textfield_form_alter(&$element, &$form_state, $context).
it isn't practical to change form

chi’s picture

@lazzyvn, You cannot use hook_field_widget_WIDGET_TYPE_form_alter() with Double field. Use hook_field_widget_form_alter() instead.