-
20 May 2010 10:25 PM #1
Dynamically generate and populate a FormPanel
Dynamically generate and populate a FormPanel
Hi All,
The question has already been asked a fair bit on the internet but I couldn't get my hands on a solution that actual works.
What i'm trying to achieve is the following:
1. retrieve a json array using ajax which contains the definition of the form to generate
2. parse that array and add into a FormPanel all required TextField
3. render the result into the interface
At the moment I'm pretty much adding text fields to the FormPanel using the add() function (i.e. form.add(field)). The TextField becomes visible on the page but when I submit the form by clicking on the button, the content of that field does not get posted to my server.
Any solution or workarounds?
Thanks for your time.Last edited by yoyoyo; 20 May 2010 at 11:59 PM. Reason: typo in the title
-
23 May 2010 10:42 AM #2
Hi, I'm currently working on the same thing - I haven't got it completely figured yet, as I'm still in the process of getting all the elements configured how I need them, but perhaps this thread will help you. If I figure it out, I'll try to remember to let you know how I did it.
http://www.extjs.com/forum/showthrea...699#post466699
-
23 May 2010 12:45 PM #3
i created a very easy example. The form is generated by a php file where i randomly create fields.
Online example with source:PHP Code:<?php
$action = $_REQUEST['action'];
$out = array();
$fieldTypes = array('input','textarea','int','checkbox');
if ($action) {
if ($action === 'getForm') {
for ($i = 0; $i < 10; $i++) {
$out['data'][] =
array(
'name' => 'field' . ($i+1),
'label' => 'Field ' . ($i+1),
'type' => $fieldTypes[rand(0,3)],
'value' => 'V' . rand(1111, 9999)
);
}
}
echo json_encode($out);
}
?>
http://dev.sk-typo3.de/ext/jsonform.htmlvg Steffen
--------------------------------------
Release Manager of TYPO3 4.5
energlobe.de - german online magazine
-
23 May 2010 11:18 PM #4
Hello,
I'm actually *thinking* about something very similar for an ongoing project.
Nothing I can add to your knowledge at this time, apart from the fact that in such case I would concentrate in client side checking rules.
When you're in need of creating the form dinamically, there's also a very high chance that this form is going to be very complex and require complex validation rules, which would be nice to implement at client side as well.
Also, to keep it even more complex, there might be a strong need to show some fields only if some other fields exists/has a certain value.
ie:
if (comboBox.value == '3') {
showField(x);
} else {
showField(y);
}
If you're developing some kind of 'standard' I think you should not avoid such a features, or at least plan for them.
M.
-
15 Oct 2010 3:57 AM #5
Hello Friends,
I think now anyone of you might got this answer...
I am also stuck here for the same situation. Please give reply on my thread.
http://www.sencha.com/forum/showthre...604#post525604
Please please do some help. I am assuming that you solved your problem as this thread is very old
Similar Threads
-
unable to dynamically generate a treepanel
By pailyanish in forum Ext 3.x: Help & DiscussionReplies: 1Last Post: 30 Sep 2009, 1:03 AM -
Viewport generate items dynamically ?
By Fabyo in forum Ext 2.x: Help & DiscussionReplies: 0Last Post: 18 Nov 2008, 8:57 AM -
Dynamically Generate Window
By hanson72 in forum Ext 2.x: Help & DiscussionReplies: 2Last Post: 22 Aug 2008, 9:57 AM -
Dynamically generate column panel via ajax request
By Zakaroonikov in forum Community DiscussionReplies: 0Last Post: 26 Mar 2008, 9:38 PM -
How to Generate Combo values dynamically based on previous selection
By msuresh in forum Ext 2.x: Help & DiscussionReplies: 6Last Post: 14 Jan 2008, 9:33 AM


Reply With Quote