RE: [PEAR] QuickForm Hierselect moving javascript
| From: | Mark Steudel | Date: | Mon, 14 Nov 2005 22:17:32 +0000 |
| Subject: | RE: [PEAR] QuickForm Hierselect moving javascript | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21922@lists.php.net to get a copy of this message | ||
I'm using a combination of the default renderer and smarty.
I access the QF form as a array ( e.g.$formData = $form->toArray( true); ),
assign $formData[javascript] to my smarty variable {$javascript} which is in
the head. Then I spit out the QF form as html strip out the javascript with
preg_replace and assign the remainder to a smarty variable {$body}.
Here's my code:
function display_form( &$form, &$tpl )
{
$formData = $form->toArray( true);
if ( isset( $additionalJavascript ) )
{
$formData[javascript] .= $additionalJavascript;
}
// put javascript into head
$tpl->assign('javascript', $formData[javascript]);
// put form out side of table elements
$tpl->assign('formattributes', $formData[attributes]);
// put hidden fields outside of table elements
$tpl->assign('hidden', $formData[hidden]);
// remove empty tags for xhtml compliance
$html = str_replace( '<b></b>', ' ', $form->toHtml() );
// cut out any javasript that's generated
$html = preg_replace( '@<script[^>]*?>.*?</script>@si', '',
$html );
// cut out the form tag generated by quickform
$html = preg_replace( '@<form[^>]*?>@si', '', $html );
// cut out the end of the form
$html = str_replace( '</form>', '', $html );
// cut out the hidden fields
$html = preg_replace( '|<input.*?type="hidden".*?/>|','', $html
);
// assign what's left of the quick form to my smarty page
$tpl->assign( 'body', $html );
}
Though now I added a hierselect the javascript is in the html key, e.g.
$formData[sections][0][elements][3][html]. The idea of looping through the
formData looking for hierselects doesn't seem to appealing. I've got a site
that's got a lot of forms on it, and I like what QuickForm generates, I just
want to move some things around to make things more XHTML compliant.
TIA Mark
>-----Original Message-----
>From: Justin Patrin [mailto:papercrane@gmail.com]
>Sent: Monday, November 14, 2005 11:32 AM
>To: Mark Steudel
>Cc: PEAR general list
>Subject: Re: [PEAR] QuickForm Hierselect moving javascript
>
>On 11/14/05, Mark Steudel <mark@netriver.net> wrote:
>> Why does the element hierselect put it's javascript into
>it's HTML key
>> versus the JAVASCRIPT key? How can move this up into the
>javasript key?
>>
>
>key? What renderer are you using?
>
>--
>Justin Patrin
>