Re: DataObjects Formbuilder - Trouble getting started
| From: | Justin Patrin | Date: | Mon, 27 Feb 2006 23:46:57 +0000 |
| Subject: | Re: DataObjects Formbuilder - Trouble getting started | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-23150@lists.php.net to get a copy of this message | ||
On 2/27/06, Sasha Sklar <spyrral@gmail.com> wrote:
> I see. I thought 'processForm' was a callback that you wrote yourself.
No, it's part of FormBuilder. It wouldn't be nearly as useful if you
had to process your forms manually.
> If it's always called, why is it a parameter?
Look closer. You're calling process on the QuickForm that FormBuilder
returns. QuickForm is a different package and uses this syntax to
process the form. FormBuilder's examples use this because it's the
accepted way to process a QF.
>
> On 2/27/06, Justin Patrin <papercrane@gmail.com> wrote:
> > On 2/27/06, Sasha Sklar <spyrral@gmail.com> wrote:
> > > I'm trying to dive into Formbuilder. I've been using DB_DataObjects
> > > for a while now, with great results.
> > >
> > >
> > >
> > > The form displays, but hitting submit does nothing but display the
> > > frozen form. No row is inserted.
> > >
> > >
> > >
> > > Using the basic example from the docs and a table named "do_test",
> > > here's the code I've written:
> > >
> > >
> > >
> > > <?php
> > >
> > > // includes
> > >
> > > require_once // database connection string
> > >
> > > require_once 'DB/DataObject/FormBuilder.php';
> > >
> > >
> > >
> > >
> > >
> > > function fooBar() {
> > >
> > > print ('is this called?')
> > >
> > > return true;
> > >
> > > }
> > >
> > >
> > >
> > > $do_test =& DB_DataObject::factory('do_test');
> > >
> > >
> > >
> > > $do_testFB =& DB_DataObject_FormBuilder::create($do_test);
> > >
> > >
> > >
> > > // set up preferences for
> > >
> > > $form =& $do_testFB->getForm();
> > >
> > > if($form->validate()) {
> > >
> > > $form->process(array(&$do_testFB, 'fooBar'), false);
> >
> > Ummm....why are you passing 'fooBar' here. This is why it's not
> > working. You should be passing 'processForm', as the docs and examples
> > say. 'processForm' is the function in FB that processes the form....
> > See: http://opensource.21st.de/19.html
> >
> > >
> > > //this is optional, you can comment out this to make the
> > > form appear for editing again
> > >
> > > $form->freeze();
> > >
> > > } else {
> > >
> > > echo 'no validate for j00!';
> > >
> > > }
> > >
> > >
> > >
> > > echo $form->toHtml();
> > >
> > > ?>
> > >
> > >
> > >
> > > Do_test is just a auto_increment key and a single varchar field. Can I
> > > get a hint?
> > >
> > >
> >
> >
> > --
> > Justin Patrin
> >
>
>
> --
> Sasha Sklar
> http://www.spyrral.net/
> spyrral@gmail.com
>
--
Justin Patrin