-
Notifications
You must be signed in to change notification settings - Fork 649
override input templates #57
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
Comments
Hi @iivvoo, I believe you can use the I do know you can also duplicate the entire Hope that helps a bit! |
Hi @iivvoo as @mike-marcacci stated above you can basically copy the decorators/bootstrap folder, edit bootstrap-decorator.js and rename it. You probably also want to edit the gulp file so it builds a version for your new decorator as well. Setting |
Thanks @mike-marcacci and @davidlgj But if I understand correctly, the decorator solution does mean I need to fork / build my own bootstrap-decorator.js? Wouldn't a more generic solution be more flexible? (I'm not sure how easy it is to just rip out the decorator stuff) I can imagine other cases where you may want to render fields differently from the default (but the form-horizontal is a very obvious one of course). My client might be willing to sponsor such a feature.. |
Hi @iivvoo, it turns out that it is quite easy to override a single template (or add new ones). For example: 1 - Create your template <div class="form-group has-feedback" ng-class="{'has-error': hasError(), 'has-success': hasSuccess()}">
<label ng-show="showTitle()">{{form.title}}</label>
<span class="help-block">{{ (hasError() && errorMessage(schemaError())) || form.description}}</span>
<textarea class="form-control"
ckeditor
sf-changed="form"
ng-required="form.required"
ng-model="$$value$$"
schema-validate="form.schema"></textarea>
</div> 2 - Use the .config(['schemaFormDecoratorsProvider', function(decoratorsProvider){
decoratorsProvider.addMapping('bootstrapDecorator', 'ckeditor', 'path/to/ckeditor.html');
}]) |
This is exactly the type of solution I was looking for. It works perfectly, thanks! |
Glad to help! |
I've started to write some docs on it: https://github.com/Textalk/angular-schema-form/blob/development/docs/extending.md |
Hi, i'm angularjs noob :) wher i need write this .config(['schemaFormDecoratorsProvider', function(decoratorsProvider){
decoratorsProvider.addMapping('bootstrapDecorator', 'ckeditor', 'path/to/ckeditor.html');
}]) i think need some file like extendForm.js but dont know how use that function :( |
I've copied the explanation of @mike-marcacci from ticket json-schema-form#57 and add as an example in the Decorators section.
@mike-marcacci Do we need to put the custom template in $templateCache? Is there a step by step example on how to override the input templates? Thanks, |
I (think I) need to override the individual (html) field definitions. I want to render my form horizontally (class=form-horizontal) but I understand this requires the input control to be wrapped in a div with a specific grid sizing class (e.g. col-md-8)
What options are there (besides forking :) to override the fields templates?
The text was updated successfully, but these errors were encountered: