This module allows the users who configure form to add a text description related to a group of fields. Then it is easier for the user of that form to get information on particular use cases of the form. Actually the description attached to a form field is useful but can be a bit narrow in several cases. At the same time, the use of the field_group module can help to organise field but there is no way to describe an add information for users. That's why this module combine the two approches, with the availability of adding a useful description for several fields.

Project link

https://www.drupal.org/project/form_helper_widget

Git instructions

git clone --branch 8.x-0.x https://git.drupalcode.org/project/form_helper_widget.git

PAReview checklist

https://pareview.sh/pareview/https-git.drupal.org-project-form_helper_wi...

Comments

tsecher created an issue. See original summary.

avpaderno’s picture

Thank you for applying! I added the Git instructions for non-maintainer users and the PAReview checklist link. Reviewers will check the project and post comments to list what should be changed.

If you haven't done it, yet, please check the PAReview report and fix what needs to be fixed. There could be some false positives; verify that what reported is correct, before making any change.

avpaderno’s picture

Status: Needs review » Needs work
/**
 * Form Helper group element.
 *
 * @FieldGroupFormatter(
 *   id = "form_helper_field_group",
 *   label = @Translation("Helper group"),
 *   description = @Translation("Add an adminstrable description text before
 *   wraped fields"), supported_contexts = {
 *     "form",
 *     "view"
 *   }
 * )
 */

In annotation, each key needs to go on each own line. (There is also a typo on adminstrable and wraped.)

The README.txt file contains lines longer than 80 characters. The extension of the file itself should be .md, since it's a Markdown file.

tsecher’s picture

Status: Needs work » Needs review

Thank you for your review. I am sorry, it is the first time a submit a module for the security advisory coverage.
I update the sources so you can download them by :
git pull origin 8.x-0.x

mostepaniukvm’s picture

Status: Needs review » Needs work

Thanks for contribution!

I checked the code and find some questions.

I tried to add helper group to form mode page and get next notice:

Notice: Undefined index: value in Drupal\form_helper_widget\Plugin\field_group\FieldGroupFormatter\FormHelperFieldGroup->settingsForm() (line 78

'#default_value' => $description['value'],
You have to correct default value.
Also, look at defaultContextSettings method:

  /**
   * {@inheritdoc}
   */
  public static function defaultContextSettings($context) {
    $defaults = [
      static::FIELD_DESCRIPTION => ['format' => 'full_html'],
      'required_fields'         => $context == 'form',
    ] + parent::defaultSettings($context);

    if ($context == 'form') {
      $defaults['required_fields'] = 1;
    }

    return $defaults;
  }

I think you have to use parent::defaultContextSettings instead of parent::defaultSettings
and looks like this rows is not required

    if ($context == 'form') {
      $defaults['required_fields'] = 1;
    }

form_helper_widget.info.yml
We don't have to set "drupal:field" as a dependency because field_group module already did it.

Also, I don't sure about indentation like here:

      'variables' => [
        'title'       => NULL,
        'description' => NULL,
        'content'     => NULL,
      ],

Does drupal coding standards allows it? Because I used to set only one space after array key.

avpaderno’s picture

The indentation is always 2 spaces, as per Drupal coding standards. This means that the following code is correctly formatted, since the indentation is increased by 2 spaces each time.

function form_helper_widget_theme() {
  return [
    'form_helper_widget' => [
      'variables' => [
        'title'       => NULL,
        'description' => NULL,
        'content'     => NULL,
      ],
    ],
  ];
}
tsecher’s picture

Thank you for all the time spend on review.

I updating the sources according to your recommandations.
You can download the new sources by :
git pull origin 8.x-0.x

tsecher’s picture

Status: Needs work » Needs review
crafter’s picture

One issue to fixed maybe it's not a problem but for people who are going to use that module can be important.
In your twig template templates/form-helper-widget.html.twig is lack comment variables at the beginning of the file.
Documentation said that we should add some available variables.
For example

{#
/**
 * @file
 * Default theme implementation to ....
 *
 * Available variables:
 * - attributes: HTML attributes to apply to the <table> tag.
 * - next variable
*/
#}
crafter’s picture

Status: Needs review » Needs work
klausi’s picture

Status: Needs work » Reviewed & tested by the community

Reviewed the code, looks good to me! Did not see any security issues.

The doc block in the template is a nice to have, but not an application blocker. I think this is ready to be approved!

avpaderno’s picture

Assigned: Unassigned » avpaderno
Status: Reviewed & tested by the community » Fixed

Thank you for your contribution! I am going to update the project to opt it into security coverage.

These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

Status: Fixed » Closed (fixed)

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