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

Show help text alongside field if specified #1150

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

stevehalford
Copy link

@stevehalford stevehalford commented Jul 12, 2016

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
Copy link
Contributor

RichardBradley commented Jul 25, 2016

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
Copy link
Contributor

RichardBradley commented Aug 4, 2016

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
Copy link

d1b1 commented Aug 23, 2016

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

@stevehalford
Copy link
Author

Just cherry-picked your commit @RichardBradley

@@ -9,7 +9,7 @@
"url": "git://github.com/marmelab/ng-admin.git"
},
"devDependencies": {
"admin-config": "^0.11.0",
"admin-config": "stevehalford/admin-config#field-descriptions",
Copy link
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
Contributor

Can you add some unit tests for your directive?

@jpetitcolas
Copy link
Contributor

👍

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

@RichardBradley
Copy link
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