Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a standard "help" element #2546

Closed
quicksketch opened this issue Feb 18, 2017 · 5 comments · Fixed by backdrop/backdrop#1794
Closed

Create a standard "help" element #2546

quicksketch opened this issue Feb 18, 2017 · 5 comments · Fixed by backdrop/backdrop#1794

Comments

@quicksketch
Copy link
Member

quicksketch commented Feb 18, 2017

In dozens of places throughout core we have a pattern of creating a "help" element with the following code:

$form['help'] = array(
  '#markup' => '<p>' . t('Help text') . '</p>',
);

We should create a standard element so that help text is displayed consistently. e.g.

$form['help'] = array(
  '#type' => 'help',
  '#markup' => t('Help text'),
);

This would allow themers to override theme_help() if needed, and we could standardize whether a <p> tag is added or not.


PR backdrop/backdrop#1794

@quicksketch
Copy link
Member Author

The PR at backdrop/backdrop#1794 adds the following:

  • Adds a help element as described above, and replaces all the locations where we had added $form['help'] in a form structure.
  • Creates markup such as:
<div class="help"><p>The help text.</p></div>
  • <p> tags are automatically added if missing. But allow for them to be present with #markup if the help text needs multiple paragraphs of explanation.

@klonos
Copy link
Member

klonos commented Feb 19, 2017

Seems a simple change to me and it is backwards compatible as in if someone still uses the "old", #markup way, things will still work. 👍

@quicksketch
Copy link
Member Author

Great thanks for the review @klonos! Merged backdrop/backdrop#1794 into 1.x for 1.7.0.

@klonos
Copy link
Member

klonos commented Mar 14, 2017

Shouldn't https://api.backdropcms.org/form_api be updated to include this?

@jenlampton
Copy link
Member

jenlampton commented Apr 30, 2017

I've updated the Form API docs at https://api.backdropcms.org/form_api#help. Can someone confirm that #attriubutes will work? I think I got everything else.

edit: I checked the PR and it looks like #attributes will not work, so I've removed that X from the grid. Closing this issue :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants