Re: Invoice editing in QF/DataObject or FB?
| From: | Justin Patrin | Date: | Mon, 21 Mar 2005 22:43:17 +0000 |
| Subject: | Re: Invoice editing in QF/DataObject or FB? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-18216@lists.php.net to get a copy of this message | ||
On Mon, 21 Mar 2005 13:05:48 -0800, Ken Restivo <ken@restivo.org> wrote:
> I need to implement the following common pattern, and I don't want to reinvent the wheel.
> In fact, I don't want to invent it at *all*, if I can avoid it.
>
> The most familiar example of the problem is an "invoice screen", that lets you start
> up a new invoice, enter the information that goes into the "invoice" table, then also
> shows a summary (HTML_Table or frozen QF) of each of the "line items", whose data goes
> into the line_items table. I need to show all the line items, and let people add/remove/edit line
> items, coming BACK to the invoice screen when they are done (or ideally expanding/hiding the line
> items-- but probably not possible due to prohibition against nested forms in HTML).
>
> This pattern is needed in a half-dozen other places in my application. In fact, I'd
> imagine it's incredibly common in relational database applications: a million interlinked
> tables, that the users have to edit and deal with.
>
> A corrolary to this is the case where the user is choosing from a pop-up the linked fields (in
> this case using ->fb_linkDisplayFields), but more often than not needs a "NEW" or
> "OTHER" button to add one that *isn't* in the database: so the pop-up needs a
> "New" or "Other" link next to it, which will bump them to a screen to enter a
> new record for the linked table, then after validating and processing, go back to where the user was
> (with all their other data intact!) with the new record's ID pre-selected in the pop-up.
>
> Again, I cannot imagine how anyone can build a usable interface to a relational database
> without this, so I can't possibly be the first to bump up against this. There must be example
> PEAR code galore. Unfortunately, I haven't had luck finding it.
>
> Are there any examples of this kind of "invoice screen" in QF/DataObjects or FB?
> It's similar to a "shopping cart", so I'd assume this has been done a million
> times.
>
That's a pretty tall order. FormBuilder is supposed to fill a lot of
that gap, however. I assume you've already started using it as you
know what it does. Did you know about the linkNewValue option in the
newest release? It allows you to enter a new value for a linked field.
In the current release it's on by default but in the next it will be
off by default. Anyway if you set $fb->linkNewValue or
$do->fb_linkNewValue to true it will put a form for a new record for
that link in a hidden div and display it if the user selects "--New
Value--" in the drop-down.
As for multi-page forms there's HTML_QuickForm_Controller, but I've
never used that myself.
For listing records I like to use Structures_DataGrid and I actually
wrote a package called DB_DataObject_FormBuilder_Frontend which gives
you a list of tables and lets you browser, edit, delete, and insert
records in any table (using FormBuilder and Structures_DataGrid). it
is probably not quite what you need, but it has lots of code you can
re-use in it. The individual classes are supposed to be directly
re-usable, but I haven't quite gotten that far.
http://www.reversefold.com/PEAR/DB_DataObject_FormBuilder_Frontend/
--
Justin Patrin