|
Posted by Kenneth Downs on 06/14/05 17:14
DJ Majestik wrote:
> OK, I am devising a php page that will handle a form submission, and
> wanted to know if anyone has already setup such an idea, or if you had
> links to point to good tutorials on this.
>
> Basically I have a form (which I use smarty templating to display, and
> smartyvalidator to validate).
>
> The php page basically is driven by the action variable (add,
> add_confirm, edit, edit_confirm, view, delete). When the form starts
> out, it is in view mode. Then if you click the add button, it switches
> to add mode. Confirming a new addition sends you into add_confirm
> (which would write to a DB, etc.). Edit would work the same way, except
> edit mode would lookup a record to display, edit_confirm would update
> that record, delete mode would delete, and view mode would basically
> display data (to edit/add/delete).
>
> Sounds easy, but my code is pretty long and I am looking to simplify
> this idea. Looking for how you all do this, and if anyone has a
> "template" setup to do this.
>
> Mine would be something like:
>
> if ($action == "view") {
> // do something
>
> .... etc ....
>
> Ideas? Let me know. Thanks,
> Jim
I don't know what you mean by "long", but our body of code that does this
is:
1) The HTML file at 332 lines
2) The processing file at 155 lines
3) About 200 lines of code in our main library
Each table also has a separate file that defines all of its parameters, but
these are computer-generated so we don't really think about length.
So anyway, your basic approach seems sound, but I'll warn you of one thing
we ran into. We allow two states, a browse of search results, and a
one-row detail view. This complicates the code a bit.
We've done away with the switch-to-edit-mode, it is not really necessary.
When a user views a row, they can save or not save, they are always in edit
mode.
We've done away with fancy client-side javascript control of the page and do
lots of round trips to the server. Here is one reason. If the user is
editing a row, then the column "state" might be a drop-down list of US
States. But if the user is in "search" mode, then you want free-form entry
there.
Hope this helps, we have done a complete version of this so I'd be happy to
answer any questions I can.
--
Kenneth Downs
Secure Data Software, Inc.
(Ken)nneth@(Sec)ure(Dat)a(.com)
Navigation:
[Reply to this message]
|