I want to create a view layout that I can re-use for multiple kinds of form input controls. For example, all form inputs are going to have:
- A label
- Some kind of input control
- Help text
- A placeholder for validation error messages
This is going to be a consistent component throughout the application. The only thing that will change between instances is going to be the input component. It could be, for example, a text field, text area, select, radio buttons, or whatever.
It seems like it would be possible to extract this into some kind of template, and just swap out the input control bit:
<label {{bindAttr for=view.someId}}>{{view.label}}</label>
{{something-goes-here}}
<span class="help-inline">{{view.help}}</span>
<span class="validation">{{view.validation}}</span>
I'm not sure if this is even possible though. It looks like a view layout might be the way to go, but for some reason self-closing tags aren't permitted to have layouts, so:
{{view Ember.TextField layout=myControlLayout ...}}
is out of the question (as a side note, why is this?)
Would it be possible to do this using just views? Or would a handlebars helper be more appropriate?
My question is very similar to this one, but differs in that I want to be able to use my view with any content.