Skip to content
This repository has been archived by the owner on Nov 30, 2018. It is now read-only.

New Feature: "url" pair for member/elements #22

Closed
Corneloues opened this issue Oct 28, 2011 · 5 comments
Closed

New Feature: "url" pair for member/elements #22

Corneloues opened this issue Oct 28, 2011 · 5 comments

Comments

@Corneloues
Copy link

The request to to add a "url" pair to member and element lists for the dForm plugin. The syntax would be of the format:

"url" : "http://...."

and would be applied as follows:

...
"elements" :
    [
        { "url" : "http://example.com/json/element-list.json" }
    ]
...

In th case of an accordion, the .json file would contain one or more of the following:

{
"caption" : "Customer Information",
"elements" : [ {...} ]
}

In the case of a the .json file would contain: { "value", "text", "value", "text", "value", "text", "value", "text" } This would allow for truly dynamic forms. Cheers, Roy

@daffl
Copy link
Owner

daffl commented Oct 28, 2011

That's a good idea. Actually I think I will implement a URL subscriber that loads a JSON file and generates the form into any element.

@Corneloues
Copy link
Author

By when ;-)

@daffl
Copy link
Owner

daffl commented Oct 28, 2011

Well I actually just pushed some of the updates. It's pretty straightforward and easy to add, too:

$.dform.subscribe('url', function(options, type) {
    this.buildForm(options);
});

Should already do the trick to do something like this:

{
    "type" : "div",
    "url" : "myform.json"
}

@Corneloues
Copy link
Author

So I'm trying to think how to translate that in to something I need.

I have several reusable sub forms which I will present as a collection of Accordions. So I want to be able to store them as JSON and include them alng the lines of:

{
"action" : "index.html",
"method" : "get",
"elements" : [
{
"type" : "accordion",
"caption" : "Job Closure (Complete)",
"entries" : [
{
"type", "accordion",
"url", "accordion1.json"
},
{
"type", "accordion",
"url", "accordion1.json"
},
{
"type", "accordion",
"url", "accordion1.json"
}
]
}
]
}

Where each jso file would contain:

{
"caption" : "Customer Information",
"elements" : [ {...} ]
}

And even the "elements" here could be a JSON file.

How would the syntax work?

Cheers,

Roy

@daffl
Copy link
Owner

daffl commented Nov 1, 2011

Each entries object is nothing more but a div wrapper (which is why you don't need the type). Have you tried

"entries" :
[
    {
        "url", "accordion1.json"
    },
    {
        "url", "accordion1.json"
    }
]

? If the URL subscriber works properly this should just do it.

@daffl daffl closed this as completed in f99e55d Jun 5, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants