Welcome Guest, Not a member yet? Register   Sign In
XML form generation
#1

[eluser]Maglok[/eluser]
At work I get a lot of requests for forms in webapplications. Recently a client wants a dynamic form creation tool.

I figure I can write a parser that reads XML and outputs a proper form.

Then I realised, somebody has probably done it before.

There is a library in the wiki, but it is from 2006. Maybe there is also a non-CI library I can convert? Has anyone done this yet or do I need to invent a wheel? Smile
#2

[eluser]Nick_MyShuitings[/eluser]
Check out formation by Dan Horrigan, or Formatic by some other guy.

I have a fork of Formation that uses his Array structure (not XML) to read a DB table and create a fitting form.

Both of those I think are based on arrays or objects, but converting an XML to the proper array format would be a lot less work then the rest of the library.
#3

[eluser]Maglok[/eluser]
I looked at formation but on Dan's site the like appears dead. Do you have any links for those two?
#4

[eluser]Nick_MyShuitings[/eluser]
Yeah, unfortunately Dan kinda abandoned it, but he is busy as all can be so its understandable.

here's the fork tree, you can see my fork underneath... its horribly documented but adds the ability to pass it a table name from the db and it makes it a form for you based on naming conventions and data types.

https://github.com/dhorrigan/Formation/network

The next step I am working on now, is integrating it with the DataMapper ORM, so that once you have the models made, you also have matching forms which share the same validation rules across JS, PHP, and DB.

If only I had more free time.
#5

[eluser]Maglok[/eluser]
I have been trying to get formatic to work. No luck. First I figured it was the liberal use of short opentags, but nope. It just doesn't parse. I am looking into formation now. Otherwise I might just have to start writing myself.
#6

[eluser]Nick_MyShuitings[/eluser]
I was interested recently in this one:
http://www.frankmichel.de/formgenlib/

Although I'll have to redo my toolkit to swap out formation, this looks significantly slicker with the chaining and whatnot instead of reading an array/xml.
#7

[eluser]Maglok[/eluser]
I have actually used that a lot before. As with the others it lacks being able to read a form from 'outside'. Though now that I have looked at formatic and formation I noticed that formatic is quite low on docs and seems a bit all over the place. Formation looks nice, but it's feature set isn't big enough for what I need to do. So I think I am going to fall back on Formgenlib and write a XML generation on it or something. Smile
#8

[eluser]Mark Croxton[/eluser]
@Maglok

Hi, I'm the author of the Formatic library. Now you're right that it's low on docs but it's somewhat unhelpful to say it's 'all over the place' without being specific. I've never 'officially' announced the library or promoted it because I know the docs aren't ready and it's a complex beast, but what's happened is that people have found the library on Github and are using it anyway!

I wrote formatic because I was frustrated with the tedious and messy process of validating and repopulating form controls. I wanted a system for abstracting form building that would allow minimal and clean views and controllers. I also wanted it to be extensible so that I could plugin specialised and advanced controls like sliders, maps, WYSIWYG, recaptcha etc. Formatic has to deal with the rendering of form control html from templates, parsing field configurations, validation rules and callbacks, loading form plugins and associated javascript/css assets on demand, data retrieval and certain specialised actions like moving uploaded files and checking CSRF tokens.

HTML form building is a messy business, there's no way round it - and Formatic is designed to free you from it by abstracting and formalising the process via configuration arrays. As such it could indeed function as a layer in your form building GUI.

If you have problems getting it installed or useful feedback on the library design I'd be happy to discuss it with you.

Mark
#9

[eluser]Maglok[/eluser]
Hey there,

What I mean with 'all over the place' is that there are assets, libraries, bridges to Carabiner and Stuff, a seperate directory of forms (application/formatic), etc. I figured it might just be a tad bit to large for me.

I tried installing it, but I could not get it to work. I did what you recommend for installation. I went with the Carabiner bridge, since that is what I have used before. I installed carabiner. Used the config file you supplied. I then went into the formatic.php config and put the bridge on carabiner.

I also enabled short open tags for PHP, cause your views use <? ?>, and that setting is off by default over here. This made the library load after I put it in autoload. The basic CI welcome message appeared, all fine and dandy.

When I try to load the example, I keep getting an empty screen though, suggesting it is going wrong in that code. So I try to echo anything at the start of the class, again nothing. Which leads me to believe syntax somewhere.

I restarted with a clean CI and got the same issue. I then moved on, cause I had no idea what was wrong.

And don't get me wrong, it looks impressive, but the lack of docs really scares me a little. Wink
#10

[eluser]Mark Croxton[/eluser]
Thanks for getting back to me with some detail.

The example form uses a reCaptcha field and a GoogleMap field - did you enter your own API keys for these services in the configuration file? Could be the page was hanging because of no response from the relevant servers.

Other than that - did you use the latest Carabiner version? Are you using CI 1.x or 2 (I tested with both, but this may have some bearing)?

Cheers

Mark




Theme © iAndrew 2016 - Forum software by © MyBB