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

Reapplying the "works with inputs without the form-control class", but in a working fashion #37

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

Conversation

smebberson
Copy link

I had a look at the code added and then later reverted that allows this directive to "work with inputs without the form-control class". The code was fine but the query selector was a little too specific.

I made a fork of your repo, git cherry-picked e93c512acc619c179d191ae6692a17c6bcef50c5 and then made some amendments so that it works on a broader range of form inputs (including select).

Would you consider using this code and reapplying the commit that was later reverted? I don't mind if you use this PR or not, but I would love for that code to make its way back into MASTER.

Let me know what you think.

@zakhenry
Copy link

Hi @smebberson , this approach is an improvement, as it will work with more inputs, but is still sub optimal, as it won't work with any custom directives that act as inputs (have validators and attach to the form by name).

My recommendation would be to have a method on the provider to specify a selector. It should default to .form-control[name] per bootstraps convention, but allow the developer to define their own convention on config.

@smebberson
Copy link
Author

@xiphiaz, that's a fantastic idea! I'll see if I can find the time to squeeze it in. I'm don't use coffeescript that regularly either, but I'll see how I go.

@egorovpavel
Copy link

it also may be simplified to *[name] (#44 ) without breaking

@chrisfosterelli
Copy link

I think simplifying makes more sense because it adds support for radio buttons

@chrisfosterelli
Copy link

If anyone's interested (since it seems like this repo doesn't get much attention), @dgsmith2 appears to have implemented a generic selector that works with selects and radios here: https://github.com/dgsmith2/angular-bootstrap-show-errors

@@ -21,11 +21,11 @@ showErrorsModule.directive 'showErrors',
showSuccess = getShowSuccess options
trigger = getTrigger options

inputEl = el[0].querySelector '.form-control[name]'
inputEl = el[0].querySelector 'input[name],select[name],password[name],email[name],datetime[name],datetime-local[name],date[name],month[name],time[name],week[name],number[name],url[name],search[name],tel[name],color[name],textarea[name]'
Copy link

Choose a reason for hiding this comment

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

don't leave out the .form-control[name], because there may be other inputs (custom elements) that behave like form controls that you are missing now.

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

Successfully merging this pull request may close these issues.

6 participants