Re: Form Design Advice

Поиск
Список
Период
Сортировка
От Ross Gohlke
Тема Re: Form Design Advice
Дата
Msg-id 50510.4.62.156.229.1109917625.squirrel@4.62.156.229
обсуждение исходный текст
Ответ на Re: Form Design Advice  (<operationsengineer1@yahoo.com>)
Ответы Re: Form Design Advice  (Bruno Wolff III <bruno@wolff.to>)
Список pgsql-novice
> ross, i have the logic and error checking (for both
> form entry and db process) down.  i'm just wondering
> if it is worth displaying the entry for a quick user
> visual check - not in the form, but above the form.
> for large forms, though, this takes a lot of overhead,
> although, my sessions approach could be eliminated to
> reduce lots of coding.

There's two kinds of overhead here. Processing overhead effects your
users. Coding overhead effects you. The following approach increases the
former to eliminate the latter. If performance is your main concern,
forget doing anything interesting. However, in my experience, users will
take a performance hit in stride if what they get at the end is valuable.
In your example, I would ask, how valuable to the user is the data you
want to display? Will it make her more productive or efficient? Will it
decrease her mental overhead, making her work easier, less stressful and
more enjoyable? If so, a few extra seconds is a small price to pay.

If you're worried about whether your hardware can handle the extra load, I
say get new hardware.

> you struck on something that may be even more
> important to me.  you seem to have a function that
> iterates through the form elements.

> do you have a link to a tutorial that explains this
> approach in more depth?  i'll do some web searches now
> to see what i can come up with and i'll report back.

If your form fields are named after your table fields, you have a closed
loop from which you can dynamically generate the bulk of your code.

First, call the database and build an array of field names/numbers/types.
http://us4.php.net/manual/en/function.pg-field-name.php
http://us4.php.net/manual/en/function.pg-field-num.php
http://us4.php.net/manual/en/function.pg-field-type.php

Iterate through this array to declare global form variables. I use
eval(), but I'm pretty sure there's a better way.

// EXAMPLE ELEMENT ARRAYS:
$arr[$fieldnum][0] = $fieldname;
$arr[$fieldnum][1] = $fieldtype;

foreach($arr as $a) {
  eval("\$" . $a[0] . " = \$_POST[" . $a[0] . "];";
  }

Code your form manually with the proper element names. Add a hidden
element for each visible element to pass the field's type for validation
purposes.

Use the same array to build your insert statement
when the form is submitted, corrected and validated.

$insert = "insert into table set (";
$x = 0;
foreach($arr as $a) {
  $insert .= $a[0];
  if($x != count($arr - 1)) $insert .= ", ";
  $x++;
  }
$insert .= ") VALUES (";
$x = 0;
foreach($arr as $a) {
  $insert .= "'" . $$fieldname . "'";
  if($x != count($arr - 1)) $insert .= ", ";
  $x++;
  }
$insert .= ");";




В списке pgsql-novice по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Form Design Advice
Следующее
От: "Pradeepkumar, Pyatalo (IE10)"
Дата:
Сообщение: Help on Trigger functions