Skip to content

Show help text alongside field if specified - #1150

Open
stevehalford wants to merge 3 commits into
marmelab:masterfrom
stevehalford:field-descriptions
Open

Show help text alongside field if specified#1150
stevehalford wants to merge 3 commits into
marmelab:masterfrom
stevehalford:field-descriptions

Conversation

@stevehalford

@stevehalford stevehalford commented Jul 12, 2016

Copy link
Copy Markdown

Adds help text or a description alongside fields (write only)

Related: marmelab/admin-config#72

The directives template can be overridden to achieve this #791

screen shot 2016-07-12 at 15 51 03

@RichardBradley

RichardBradley commented Jul 25, 2016

Copy link
Copy Markdown
Contributor

I think this is a great addition.

I was wondering about screen readers and whether the help text ought to be linked to the input, e.g. by a "label for". This page suggests using "aria-labelledby" instead: http://www.html5accessibility.com/tests/mulitple-labels.html

... actually this page has a better summary: https://www.w3.org/WAI/tutorials/forms/instructions/

@RichardBradley

RichardBradley commented Aug 4, 2016

Copy link
Copy Markdown
Contributor

I'm using this on my ng-admin powered site, and it works great, thanks.

I've extended the code so that you can use HTML markup and/or Angular markup in the help text where necessary. Can I create a PR for a PR? Or should I create a separate PR that includes this code?

I have some fields which change their meaning based on the "type" of the row, and I wanted the help-text to vary. You can use it like:

  myEntity.editionView()
     .fields(
        nga.field('type', 'choice')
                    .choices([ .. ]),
        nga.field('searchQuery')
                    .label("Search Query")
                    .helpText(angular.element(
                        "<small ng-if=\"entry.values.type == 'live_search_feed'\" class='help-block'>" +
                        "  This is both the \"view all\" link and the " +
                        "search which will be used to fill the product list." +
                        "</small>" +
                        "<small ng-if=\"entry.values.type == 'curated_list'\" class='help-block'>" +
                        "This will be used for the \"view all\" link. (Optional)" +
                        "</small>" +
                        "<small class='help-block'>Remember to filter the search if you want only Foo" +
                        " or only Bar typed products (usually you do; it looks neater).</small>")),

My changes are at: RichardBradley@c9f404b
(you'll need to cherry-pick that commit; it's on a branch which contains other stuff).

@d1b1

d1b1 commented Aug 23, 2016

Copy link
Copy Markdown

Any progress on this. Would love to have this feature.

@stevehalford

Copy link
Copy Markdown
Author

Just cherry-picked your commit @RichardBradley

Comment thread package.json
},
"devDependencies": {
"admin-config": "^0.11.0",
"admin-config": "stevehalford/admin-config#field-descriptions",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use new admin-config release once your marmelab/admin-config#72 PR has been released.

@jpetitcolas

Copy link
Copy Markdown
Contributor

Can you add some unit tests for your directive?

@jpetitcolas

Copy link
Copy Markdown
Contributor

👍

Please rebase this PR to ensure tests are fine. :)

@RichardBradley

Copy link
Copy Markdown
Contributor

(If you're making changes here, it would also be nice to update the docs to explain how to use the non-string case of helpText. Maybe add the example from my comment above starting "You can use it like:" to Field.md, if it still works after jpetitcolas's changes.)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants