PDA

View Full Version : Server Side Forms {JSON} 2.x - Form Builder Updated



BlackICE1979
8 Nov 2007, 6:06 AM
Hi There,
I've update the excellent Form Builder for the 2.0 Version of Extjs. Hope you'll enjoy it!
[CODE]/*
* Building a basic form :
//Prepare the form
var remoteForm = new Ext.ux.FormBuilder({url:'/task/ajaxform', params:{taskid:selectedId}});
//Some Function to handle the problem
var badDataPopup = function(f) {
console.log('Bad Data: %o', f);
Ext.MessageBox.alert('Bad Data', 'Unable to create form. Check your firebug console, cowboy!');
}
//Some Function to handle the submit that are successful
var submitsuccess = function(f){
window.hide();
}
//Some Function to handle the submit that has failed
var submitfailed = function(f){
Ext.MessageBox.alert('Error Message', action.result.errorInfo);
}
//A function to put the panel in a window (Desktop example)
//Note: The formPanel is passed as an argument on the 'validform' event.
//The formPanel is also returned as shown below.
var createWindow = function(formPanel){
window = new Ext.Window({
title: 'Compl

SeaSharp
8 Nov 2007, 6:38 AM
Hi I have been building something similar but in terms of scope and code volume you are way ahead.

Could you explain your motivation for declaring many multiple functions for the field types? So far I have had some success building a form from a single json item element array passed from the server.


this.form = new Ext.FormPanel({

..
items: formDefinitionFromServer.Elements

mdissel
8 Nov 2007, 7:07 AM
are you sure this is for Ext 2.0? Ext.form.Column doesn't exist in 2.0, use layout:column and you can use "xtype" to specify the type of field.

Thanks
Marco

BlackICE1979
8 Nov 2007, 7:22 AM
:">True True, I didn't test the whole thing but the rest work just fine. I'm just starting to use it in my project. I'll post an update soon and I plan to do the same trick with gridPanel!

See ya!

DigitalSkyline
8 Nov 2007, 4:52 PM
What advantage does this have over just sending back the actual form definition in JSON? (ala 2.0)

BlackICE1979
14 Nov 2007, 6:00 AM
Can you explain how you do it? Because I looked around and didn't find the documentation about that.
Thanks

tidal
14 Nov 2007, 9:07 AM
Hi!

The basic thing is Ext2.0 needs less more code and is pretty much straight forward.
You can (for example) replace all the functions building the different field types by this:


this.form.add(config);


where the config must at least look like something like this:


{xtype: 'radio'}


Check the Ext.Component Documentation to learn more on xtypes.

You can also check my Ext.ux.Plugin.RemoteComponent (http://extjs.com/forum/showthread.php?t=18023) for one way how to do it.
It can provide the remote functionally you need . Stick the Plugin in a
Ext.form.FormPanel and there you go. So you will have a proper separation between
the form- and the remote-functionality and you can still extend Ext.form.FormPanel,
if you need more functionality on the forms.

Timo

tavox
19 Dec 2007, 9:08 PM
:">True True, I didn't test the whole thing but the rest work just fine. I'm just starting to use it in my project. I'll post an update soon and I plan to do the same trick with gridPanel!

See ya!
When do you plan to post the update and the GridPanel???

regards

6epcepk
9 Jan 2008, 6:35 AM
Thanks for ux!
But how must seeng JSON for ComboBox. I try with:

{"type":"ComboBox","options":{"fieldLabel":"test"},"simplestore":{"fields":"['id', 'title']","data":"[[1, 1], [2, 2]]"}}
But no errors, no data...