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

HowTo address nested json-schema-fields #182

Open PiQ99 opened 9 years ago

PiQ99 commented 9 years ago

Hey great Alpaca-Guy,

as I already posted on the specific page, I also wanted to create a new issue - it is actually more like a question than a real issue.

If I have nested JSON-Schema-Files, is it possible to address these fields e.g. "name" & "age" first page, other things on the second page?

See the Example at: http://jsfiddle.net/gmvn6rh3/

(Already posted comment on wizards-page: http://www.alpacajs.org/docs/api/wizards.html)

uzquiano commented 9 years ago

As noted here: http://www.alpacajs.org/docs/api/wizards.html

I believe this is already possible and demonstrated by example #1. Can you verify and close if this is not an issue, otherwise provide more detail?

PiQ99 commented 9 years ago

Hey, sry for the delay.

The thing is, if I use my provided example (as binding and as schema-source) I dont get the desired output. If I use it, I get everything presented on the first page and no things at the second. If I would change the bindings to:

"bindings": { "CustomerData": 1, "OtherInfo": 2, }

it is actually working - CustomerData will be presented on first page and OtherInfo on the second. But I want to address the fields in "CustomerData" and "OtherInfo" to be presented on pages (3 fields of the first on page 1, 2 fields of "CustomerData" on the second page and so on), not the whole stucture "CustomerData" (all 5 fields on page 1) and "OtherInfo" on page 2.

Did you understand my issue? Or is it none.

Something similar to: http://jsfiddle.net/gmvn6rh3/1/

"bindings": { "CustomerData.name": 1, "CustomerData.age": 1, "CustomerData.gender": 2, "OtherInfo.info": 2, "OtherInfo.other": 2 }

PiQ99 commented 9 years ago

Something new available? :)

The Problem is, I have the incentive to create a wizard with your framework without scrolling, so I have to place properties of properties from an object on a second, third, and so on, page.

Actually I thought I found the solution while skipping through your sourcecode, if I use: "CustomerData_gender": 2 as binding but it is not working.

Happy new year btw.

PiQ99 commented 9 years ago

Well as a hint,

according to the definition of dataValues in different levels in the json-schema (in a wizard), the bindings should be defined as:

http://jsfiddle.net/gmvn6rh3/2/

"bindings": { "CustomerData": { "name": 1, "age": 1, "gender": 2 }, "OtherInfo": { "info": 2, "other": 3 } }

Neverthesless its not working, but atm I changed the way of representation the data, so its not required anymore by me.

ssreekr commented 9 years ago

Bumped into same situation - any plan for a solution?

golfmat1 commented 9 years ago

Also interested in the ability to bind by path as well, without being limited to binding top-level "groups." Any updates?

bluesodium commented 7 years ago

a problem here too....

strainovic commented 6 years ago

If you check this example http://www.alpacajs.org/demos/bootstrap/customer-profile/edit-custom-view-form.html you can see layout option in view part of JSON for /address path but it does not work :(

"/address": { "layout": { "template": "./two-column-layout-template.html", "bindings": { "street": "leftcolumn", "city": "rightcolumn", "state": "rightcolumn", "zip": "rightcolumn" } }, "styles": { "h3": { "font-size": "14px", "margin": "0px" } } },

Is there any working solution yet?

Thanks!

selfrefute commented 6 years ago

Any updates on this? I've spent all day trying to figure this out :(

madze commented 5 years ago

This would be a great feature if it doesn't exist. I've spent most of the day trying to find any support for binding to nested fields to no avail...

Any word on this one?

Thanks a bunch!

quickflows commented 5 years ago

madze, were you able to figure this one out? I have the same issue. I have an object Address with a bunch of attributes within. And I would like to layout these attributes not necessarily in the order in which they are defined in the schema. As such, being able to reference each one of the attributes individually and list them in the order I want, is more desired. I have been trying with Address.Street, Address_Street, Address/Street to no avail.