-
Notifications
You must be signed in to change notification settings - Fork 18
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
support bootstrap horizontal form #37
base: master
Are you sure you want to change the base?
Conversation
I think that this is pretty custom behaviour which can easily be added by extending the component and using a custom template.
If we could do something to make this extension process easier - like making it so you do not have to copy as much template from the default form-master template I think that would be a better way to proceed. |
@g-cassie It's of course also possible by overrides and reopen. This was the way I had this one implemented before. But I think a wrapper around these elements is required by many form markup that's why I introduced it as a PR. Also this addon is configured to work with bootstrap as default. But if you come to a decision not to include this one, it's also fine for me. |
380adb2
to
87fdf86
Compare
Rebased after #36 was merged. |
errors and help texts. This is needed for columns in bootstrap horizontal from. Example usage: ``` // routes/application.js import Ember from 'ember'; export default Ember.Route.extend({ beforeModel() { this.set('inputWrapperClass', 'col-sm-10'); this.set('labelClass', 'col-sm-2'); this.set('formClass', 'form-horizontal'); }, fmConfig: Ember.inject.service('fm-config') }); ``` You will have a bootstrap horizontal form. Column offset are not handeled automatically for fields without a label (fm-checkbox, fm-submit) or if label property is empty. As this seems to be to much bootstrap specific for this general form-builder libary. Together with Emerson#36 we could make a nice horizontal bootstrap form like this one: http://getbootstrap.com/css/#forms-horizontal ``` {{#fm-form}} {{fm-field label='Email'}} {{fm-field label='Password'}} {{fm-checkbox label='Remember me' inputWrapperClass='col-sm-10 col-sm-offset-2'}} {{#fm-submit inputWrapperClass='col-sm-10 col-sm-offset-2'}} Sign in {{/fm-submit}} {{/fm-form}} ``` Of course you should have service configuration set like above.
87fdf86
to
35eea3a
Compare
Rebased after #38 was merged. |
How about the following API?
Then we can provide some predefined layouts.
|
Thanks for digging into this. I'm not quite sure about the api. Default template and horizontal template would be very similar for my case - just two lines would be different. If bootstrap grid columns should be supported, there would be some more changes but template specific parameters would be needed. Feels like the api would not solve the DRY issue but make Also it's a little bit confusing that basic inputs, textarea and select using |
I would like to refactor so that we have a concept of a "widget". A widget is a generic term for input, textarea, select, radio group, jquery datepicker etc. It should be extensible so you can make any widget you want and still get standard label, error and help text from the fm-field class. If we had this refactor in place, I think it would be trivial to add new layouts and a lot less DRY than my example above. Also I think we could have layouts for popular css frameworks available in the form-master repo so in most cases it would be zero work. In terms of making this "widget" class, I think we really need the
So I agree the layout option above is not ideal now, but I think if we unified all the field types so there is less repetition in the code base it could have a nice syntax and be very extensible. |
That widget api looks really good. @g-cassie thanks for your work on that! Let me know if I could help you. |
Love the API as well as the notion of an extensible widget. Just need to wrap my mind around the new params and |
Introduces inputWrapperClass, an element which wraps input fields, errors and help texts.
This is needed for columns in bootstrap horizontal from.
Example usage:
You will have a bootstrap horizontal form.
Column offset are not handeled automatically for fields without a label
(fm-checkbox, fm-submit) or if label property is empty. As this seems
to be to much bootstrap specific for this general form-builder libary.
Together with #36
we could make a nice horizontal bootstrap form like this one:
http://getbootstrap.com/css/#forms-horizontal
Of course you should have service configuration set like above.