newforms-bootstrap icon indicating copy to clipboard operation
newforms-bootstrap copied to clipboard

Unable to add className to element using widgetAttr

Open switchflip opened this issue 9 years ago • 1 comments

First off I really enjoying using this library and thanks for making it. I did however come across an issue when trying to add an additional class to form element. using widgetAttr.

For example:

  advancedSettings: ->
    upc: CharField widgetAttrs:
      placeholder: "Enter Text Here"
      className: "test-class"
    taxes: ChoiceField({choices: @choices})
    modifiers: ChoiceField({choices: @moreChoices})
    allowReturns: BooleanField({required: false})

When this renders, the form only has classes from newform-bootstrap and my test-class is not applied. Any ideas whats happening?

Thank-you,

switchflip avatar Mar 26 '15 15:03 switchflip

This is the danger of pulling UI-specific stuff up to the field layer :smile:

BoostrapFIeld sets a className when rendering the Widget, which overrides any className attrs already on it.

Will look into the best place to make a change to allow both classNames to be used.

insin avatar Mar 26 '15 17:03 insin