Re: Quickform Renderer
| From: | Jeroen Houben | Date: | Fri, 04 Apr 2003 15:47:37 +0000 |
| Subject: | Re: Quickform Renderer | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-14894@lists.php.net to get a copy of this message | ||
Bertrand Mansion wrote:
<jeroen@terena.nl> wrote :I'll probably send it this weekend then.Bertrand Mansion wrote:Hi Betrtrand, Thanks for the quick reply. I already had a quick look at the code in CVS. I don't understand too much of the ITX renderer as I don't use IT/ITX. The only reason why I don't use a template system is because I haven't found a good way to make it work with quickform yet, which is why I'm so interested in the new Quickform. So yes I'll be happy to test anything you may have. Send it to me and I'll have a look at it next week.<jeroen@terena.nl> wrote :There are already a few renderers available in CVS. At the moment, you will need to checkout the cvs version if you want to test them. Let me know if this is ok with you. The renderers available are the following: - Default : This renderer uses the same kind of rendering as the one that was available in previous QuickForm versions. This way, backward compatibility is ok. - Array : This is actually the renderer that will output an array representation of the QuickForm content. It is similar to the toArray() method and is actually called when toArray() is called. The only difference with previous toArray() method is that every element gets a numeric index in the array. Previous version was a bit harder to parse. - ITX : This renderer uses the HTML_Template_ITX package. It works by looping through a 'qf_main_loop' using styles defined in other blocks. There is a possibility to attach an element to a style block. I have also made an ITX renderer that is more low level than the looping one but I am still testing it. It works differently: it uses placeholders for each elements in the form. Then, when it finds a placeholder, it replaces it by a parsed style block. It allows for very weird presentation, forms with horizontal layout, forms alternating comments and widgets... I haven't committed it yet but I can send it to you along with an example if you want. I am waiting for Alexey Borzov to give me his opinion as he is the one who wrote the first ITX renderer. If you have some time to test it, let me know. I'll send to you a few examples. I would be happy to know your opinion about both ITX implementations. Bertrand Mansion MamasamHi, I was just wondering how the development on the Quickform Renderer is going and if I can test anything yet?
As for the array renderer, I had a quick look and noticed one thing: There is still HTML in the array. I don't really understand this as HTML should only be in the template file (if you ask me). Take a selectbox for instance. A designer might want to create a selectbox that looks like this:QuickForm renders the element in the array to have it available for later use. What would you expect instead ?
<select class="weirdbox"> <options>Make your selection</option> <option style="background-color: blue;">Amsterdam</option> <option style="background-color: green;">Paris</option> <option style="background-color: blue;">Berlin</option> <option style="background-color: green;">Whoopville</option> </select>$select =& $form->addElement('select', 'myselect'); $select->addOption('Amsterdam', 'Amsterdam', array('style' => 'background-color:blue;')); $select->addOption('Paris', 'Paris', array('style' => 'background-color:green;')); And so on...
A lot of this selectbox is purely design and should be in the template. I don't see how this can be done with the array renderer, because in the array there is never a list with values for the selectbox just the actual HTML. Can you elaborate on this? Thanks!The rendered array is not meant to replace what you would do with QuickForm. If you need to modify your elements, do it with the QuickForm object. Then, when you are ready, and need an array representation, use toArray(). I am not sure I understand what you're talking about. I guess I was hoping that with the new Renderer you could chose to do all your layout things (like sizes for textboxes, background-colors for textareas etc etc) in a template. Quickform's strength (to me) is in the filters, rules, setting defaults, how it works with DataObjects etc (it's probably my favorite PEAR package, don't get me wrong), but not the layout features. I would like to delegate the design of my form to a designer who shouldn't have to use PHP, but just edit templates with a WYSIWIG editor. Will that be at all possible? If not I think it can be done and I'd like to give it a go myself. To get back to the selectbox example, I'd a renderer to return a selectbox like this: array(1) { ["elements"]=> array(1) { [0]=> array(3) {
["name"]=>
string(4) "city"
["type"]=>
string(6) "select"
["values"]=>
array(3) {
[0]=>
array(3) {
["value"]=>
string(3) "ams"
["label"]=>
string(9) "Amsterdam"
["selected"]=>
bool(false)
}
[1]=>
array(3) {
["value"]=>
string(3) "par"
["label"]=>
string(5) "Paris"
["selected"]=>
bool(true)
}
[2]=>
array(3) {
["value"]=>
string(3) "lon"
["label"]=>
string(6) "London"
["selected"]=>
bool(false)
}
}
}
}
}
That way you can do anything you want with it. Hope I've made myself clearer now, let me know.
TIA
Jeroen