Re: Formbuilder and QuickForm - Redirects and Groups
| From: | Justin Patrin | Date: | Sat, 08 Oct 2005 06:51:15 +0000 |
| Subject: | Re: Formbuilder and QuickForm - Redirects and Groups | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-21284@lists.php.net to get a copy of this message | ||
On 10/7/05, Justin Patrin <papercrane@gmail.com> wrote:
> Hello
>
> I have a couple of which I hope will be easily solved, questions about FB
> and QF. I have FB rendering to an array which is then sent to Smarty. Most
> of this is working fine
>
> 1. How do I redirect the page once the data has been submitted and passed
> validation. The error I'm getting is that a header has already been sent..
> The only reference to an example of how to fix it in this archive no longer
> exists. From Justin Patrin entitled "Re: [PEAR] formbuilder: where do you
> put a redirect statement to redirect you to another page after".
>
> "Check my FAQ entry for how to redirect.
> > http://opensource.21st.de/tiki-view_faq.php?faqId=1#q4
> > goes nowhere.
Please read all of the FAQ entries here. They're all useful.
http://pear.reversefold.com/dokuwiki/doku.php?id=phpfaqs#why_does_my_webpage_say_headers_already_sent
>
> 2. Would someone please point out to me what I'm doing wrong setting groups
> in a script.
>
> ** This works:
>
> $el = HTML_QuickForm::createElement('date','pointyearto', 'Point
> Score
> Year Ends', array('format'=> 'dFY'));
> $builder->preDefElements['pointyearto'] = $el;
>
>
> ** This doesn't:
>
> // Groups
> //
> // first set the fields
> $bankgroup['bankbsb'] =
> HTML_QuickForm::createElement('int','bankbsb', 'Bank BSB');
> $bankgroup['bankacctno'] =
> HTML_QuickForm::createElement('int','bankacctno', 'Bank Account
> Number');
>
> // add them to a group
> $group = HTML_QuickForm::addGroup($bankgroup, 'bankgroup', 'Bank
> Details', ' ');
>
> // send the group to the form
> $builder->preDefElements['bankgroup'] = $group;
>
> The error returned is "Fatal error: Using $this when not in object context
> in c:\wamp\www\myproject\include\PEAR\HTML\QuickForm.php on line 725"
>
You can't call addGroup "statically". It only works on an instance.
$form->addGroup(...);
NOT
HTML_QuickForm::addGroup(...);
You should be able to just set the group array in preDefElements.
$builder->preDefElements['bankgroup'] = array('bankbsb' =>
HTML_QuickForm::create..., 'banksomethingelse' => HTML_...);
--
Justin Patrin