Re: suggestions wanted concerning form handling "template"



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)
.



Relevant Pages

  • suggestions wanted concerning form handling "template"
    ... The php page basically is driven by the action variable (add, ... add_confirm, edit, edit_confirm, view, delete). ... edit mode would lookup a record to display, ... "template" setup to do this. ...
    (comp.lang.php)
  • Re: how to add tooltips to excel udfs i created?
    ... Can display a tooltip (a window with some text, ... userform if coding in VBA) to appear next to a cell while mouse hovers over ... Identify when user enters edit mode ...
    (microsoft.public.excel.programming)
  • Re: Session variables are lost, disappear from page to page
    ... MS Windows Server 2003 ... says 'edit records' and 'delete records'. ... the data in the session array is gone. ... I think it's a PHP bug, but PHP support won't acknowledge it as a bug, ...
    (comp.lang.php)
  • Re: Session variables are lost, disappear from page to page
    ... MS Windows Server 2003 ... says 'edit records' and 'delete records'. ... the data in the session array is gone. ... I think it's a PHP bug, but PHP support won't acknowledge it as a bug, ...
    (comp.lang.php)
  • Re: DB Result Wizard Error
    ... open the hidden folder /_fpclass/ and edit the ... > For instance Equipment Serial Number, Equipment Model Number, Cost Accounting ... > to display the new equipment information. ... > is in the table was added to the query. ...
    (microsoft.public.frontpage.programming)