backdrop-contrib / paragraphs

Paragraphs module to control your content flow
https://backdropcms.org/project/paragraphs
GNU General Public License v2.0
5 stars 11 forks source link

Change help text when there's only one paragraph bundle #27

Closed olafgrabienski closed 5 years ago

olafgrabienski commented 5 years ago

When I create content with a Paragraphs field, there is a help text like the following at top of the field:

No Paragraphs added yet. Select a Paragraph type and press the button below to add one.

The "Select a Paragraph type" part appears even when there's only one Paragraph bundle (i.e. type) available, so that there is no option to choose a type. In this case a help text without the "type" part would be better, for example:

No Paragraphs added yet. Press the button below to add one.

olafgrabienski commented 5 years ago

In case it's not possible or too complicated to have different help texts: Do we need the help text at all?

bradbulger commented 5 years ago

If an option to hide the help text and/or the contents of $add_text could be added to the variables supplied to theme_paragraphs_field_multiple_value_form() it would be easier to override this in a custom theme function, at least. Or add it to the instance config settings maybe?

olafgrabienski commented 5 years ago

@laryn What would you prefer: to differentiate or to remove the help text?

Here's the current code with the help text, https://github.com/backdrop-contrib/paragraphs/blob/1.x-1.x/paragraphs.module#L1185:

$output = '<div class="form-item">';
  if (count($items)) {
    $output .= $field_content;
  }
  else {
    $add_text = 'No @title_multiple added yet. Select a @title type and press the button below to add one.';
    if ($add_mode == 'button') {
      $add_text = 'No @title_multiple added yet. Select a @title type and press a button below to add one.';
    }
    $output .= '<label>' . t('!title !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>";
    $output .= '<p><em>' . t($add_text, array('@title_multiple' => t($instance['settings']['title_multiple']), '@title' => t($instance['settings']['title']))) . '</em></p>';
  }
  $output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
  $output .= '<div class="clearfix">' . backdrop_render($add_more_button_type) . backdrop_render($add_more_button) . '</div>';
  $output .= '</div>';

  return $output;
}
laryn commented 5 years ago

@olafgrabienski @bradbulger I'm not sure how necessary the instructions are -- it seems pretty clear typically. I'd probably be in favor of just pruning this down to simply:

No Paragraphs added yet.

What are your feelings about that? Brad, I'm open to something like what you suggested if you feel strongly and can make a PR for it.

olafgrabienski commented 5 years ago

No Paragraphs added yet.

That would be sufficient, in my opinion!

bradbulger commented 5 years ago

That would be OK. It applies well enough to cases where there is only one type, and so no "type" at all from the user's pov

laryn commented 5 years ago

Thanks @bradbulger, merged https://github.com/backdrop-contrib/paragraphs/commit/72b6bdc9a9f6313dbb562d57ca524f7412a25c1e .