Re: Partially display form elements
| From: | Ignatius Reilly | Date: | Mon, 02 Jan 2006 15:54:07 +0000 |
| Subject: | Re: Partially display form elements | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-22404@lists.php.net to get a copy of this message | ||
You can use the following hack (basic idea - to adapt):
require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('firstForm');
// The javascript showing/ hiding a "block" (set of contiguous rows)
$js = <<<JS
<script language='javascript'>
//<![CDATA[
function switch_block( b ) {
block = "block[" + b + "]" ;
if ( document.getElementById( block ).style.display == 'none' ) {
document.getElementById( block ).style.display = 'block' ;
} else {
document.getElementById( block ).style.display = 'none' ;
}
}
//]]>
</script>
JS;
echo $js;
// The switcher
$form->addElement( 'static', '', '', "<a href='javascript:switch_block( 1 )'>[+] show/ hide</a>" ) ;
// The block to hide
$display = 'block' ;
//$display = ( your default conditions here ) ? 'block' : 'none' ;
$mask_begin = "
<div id='block[1]' style='display: {$display}'>
<table><tr><td>
" ;
$mask_end = "
</td></tr></table>
</div>
" ;
$group = array() ;
$group[] =& HTML_QuickForm::createElement( 'static', '', '', $mask_begin ) ;
$group[] =& HTML_QuickForm::createElement( 'text', "title[1]" ) ;
$group[] =& HTML_QuickForm::createElement( 'static', '', '', $mask_end ) ;
$form->addGroup( $group, 'block', '', array( ' ', ' ', "<br/>" ), FALSE );
// Output the form
$form->display();
HTH
Ignatius
Alejandro López Hernández thus spake on 2005-12-27 06:47:
Hello guys, I want to partially display elements of a form, I'm using HTML_QuickForm to make the form and I need to display just parts of the same because my form is very long. I want to make something like Mambo's/Joomla's content publishing script so that I need to display the HTML code within divs in order to create tabs, but if I use display() method it prints all of the form, is it possible to display only parts of the form? Thanks for your assistance