AW: [PEAR] HTMLQuickform: Groups, grouping elements graphically, but leavingthem ungroup programmatically

From: Date: Sat, 05 Feb 2005 20:30:27 +0000
Subject: AW: [PEAR] HTMLQuickform: Groups, grouping elements graphically, but leavingthem ungroup programmatically
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17402@lists.php.net to get a copy of this message
Hi, To first question. I would not use Groups to design the form. I would use Templates. Its quite simple. You define your Form elements as usual. $form->addElement('radio','show1','Display:','Yes','Y'); $form->addElement('radio','show2',null,'No','N'); Then you define the Template system. require_once("HTML/Template/ITX.php"); require_once("HTML/QuickForm/Renderer/ITStatic.php"); Then you define wich template to use $tpl=&new HTML_Template_ITX("./inc/template" /*Template-Path*/); $tpl->loadTemplatefile("tmpl.myform.htm"); $renderer=&new HTML_QuickForm_Renderer_ITStatic($tpl); $renderer->setErrorTemplate('<font class="error">{error}</font><br />{html}'); And then you show the form $form->accept($renderer); $tpl->show(); Here is an example of the template file. <form {form_attributes}> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="left" class="normal">{show1_label}</td> <td align="left">{show1_html}</td> </tr> <tr> <td align="left" class="normal">{show2_label}</td> <td align="left">{show2_html}</td> </tr> </table> </form> To your second question $defaults = array("<checkbox>"=>1); $form->setDefaults($defaults); Greetings Mirco -----Ursprüngliche Nachricht----- Von: Aaron [mailto:lists.php.net@rare.as] Gesendet: Samstag, 5. Februar 2005 16:40 An: pear-general@lists.php.net Betreff: [PEAR] HTMLQuickform: Groups, grouping elements graphically, but leavingthem ungroup programmatically Hi there, I have googled for a soloution to this, but there is no solid source of docmentation that I could find regarding HTML quickform groups. I have also logged in to irc but had no joy there either. I have read through most of the documentation for QF but there are missing bits =/ So this is my current last resort. I want to graphically group several checkbox elements together, as they apply to a common theme. Using css with a group Element, I can have the checkboxes nicely and graphically layed out in a group like format. However I want to be able to access the values of these elements as if they were not in a group. Which would make it simpler programatically to set the boolean values in-to mysql as I currently do not know of a way to do this with grouped elements on just one line. e.g. mysql_field = " . intval($element->getChecked()) ." Q2. How about accesing those grouped element values with *one line* of script then, is this possible? I guess I want to do something like e.g. $groupElement->getElement('open_to_females')->getChecked(); (obviously this doesn't work; can you tell i'm still learning php?) I know that one soloution is to bypass the quickform methods and access the values directly from the post/get variables, but this seems a bit tardy to me. ------ Next Question I populate most variables by simply passing the array of mysql values to the $form->setDefaults method. e.g. $arr_values = mysql_fetch_assoc(mysql_query("SELECT * FROM event WHERE EventID = $EventID")); $form->setDefaults($arr_values); $arr_Open_to[] =& HTML_QuickForm::createElement('checkbox','Open_to_females',null,'Females', ($arr_values['Open_to_females'] == 1?"checked=\"checked\"":"") ); Q1. Anyone know if there is away to set the default checked value of a checkbox element to "checked/unchecked" by using $form->setDefaults or something similar? Cheers for your attention, hope you can help Aaron.

« previous php.pear.general (#17402) next »