gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

Why are messages hard-coded to append to fields elements? #260

Open musicist288 opened 9 years ago

musicist288 commented 9 years ago

Looking at this line: https://github.com/gitana/alpaca/blob/master/src/js/Field.js#L1074

It seems odd that with the pretty robust template engine, message positions are not part of it. The message template is written as a handlebars template, why not allow containers or controls to specify where messages should go with a block expression?

For example, I'm building a field where the user can input a latitude and longitude and see/interact with a street map component for setting it. If one value is present and not the other, I'd like a single validation message for the entire field to describing the error, but I don't want it appended after the map component if it's visible.

I'm aware that there's probably a way to trigger an invalid state on the number fields through a custom 'required if' validation (though it's not immediately obvious since it's not a strict dependency), however, I'm just curious if there was a specific reason for this behavior or if it was just an oversight.

uzquiano commented 9 years ago

This is a great idea. I don't think there is any particular reason why the location of messages is fixed other than that, in the original Alpaca 1.0 work that was done, it was likely assumed that forms rendered vertically and that messages appeared below. It wasn't until many iterations later and after many feature requests that placement of messages became more interesting.

I completely agree with you. I'd love to hear any design thoughts in terms of you'd describe placement of these message elements. While on the one hand it offers a lot of flexibility to let people extend templates, that kind of thing is often a bit too advanced for the beginner. Being able to say things like "top" or "bottom" might also be useful but could be too constraining as well.

Really like this idea. Just need to flesh out some ideas on how it could be best done?