Re: adding Plaintext to HTML::Form
| From: | Stig S. Bakken | Date: | Sat, 09 Mar 2002 10:28:56 +0000 |
| Subject: | Re: adding Plaintext to HTML::Form | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-4948@lists.php.net to get a copy of this message | ||
Hi,
I've committed your patch to CVS.
- Stig
On Tue, 2002-03-05 at 19:21, Ted Shieh wrote:
> Hi, could I get some feedback about the change I proposed on this mailing
> list on 2002-02-25 (shown below)? In particular, is someone going to commit
> this change in CVS?
>
> Here's an explanation of the change again:
>
> This patch adds a new form field type called Plaintext. This is useful for
> printing text in a form that the user is not supposed to edit.
>
> Here is some sample code that use Plaintext:
>
> if ($user_owns_this_entry) {
>
>
> $form->addText('input[title]','Subject',stripSlashes($input['title']),60);
>
>
>
> $form->addTextArea('input[body]','Entry',stripSlashes($input['body']),60,20);
> } else {
> $form->addPlaintext('subject',stripSlashes($title));
> $form->addPlaintext('entry',nl2br(stripSlashes($body)));
> }
>
>
> $form->addSelect('input[rating]',$rating_title,$rating_options,$default_rating);
> $form->addSubmit();
> $form->display();
>
> You can see this in action at
>
> http://www.liquidmarkets.com/m.php?m=rating&iid=33&cat=kmart_supporters
> and
>
> http://www.liquidmarkets.com/m.php?m=rating&iid=30&cat=kmart_supporters
>
> At the first URL, the text is not editable (shows up as Plaintext) because
> it is owned by another user. At the second URL, the text is editable (shows
> up in a Textfield) because it is owned by the Anonymous user. I would have
> liked to have called this Text instead of Plaintext, but Text is used for
> Textfields.
>
>
> --- Form-old.php Wed Jan 30 04:26:26 2002
> +++ Form-tedshieh.php Mon Feb 25 04:26:12 2002
> @@ -17,7 +17,7 @@
> // | Urs Gehrig <urs@circle.ch> |
> // +----------------------------------------------------------------------+
> //
> -// $Id: Form.php,v 1.22 2002/01/30 09:26:25 ssb Exp $
> +// $Id: Form.php,v 1.2 2002/02/14 01:30:57 Ted Shieh Exp $
> //
> // HTML form utility functions.
> //
> @@ -178,6 +178,14 @@
> }
>
> // }}}
> + // {{{ addPlaintext()
> +
> + function addPlaintext($title, $text = ' ')
> + {
> + $this->fields[] = array("plaintext", $title, $text);
> + }
> +
> + // }}}
> // {{{ start()
>
> function start()
> @@ -468,6 +476,27 @@
> }
>
> // }}}
> + // {{{ displayPlaintext()
> +
> + function displayPlaintext($text = ' ')
> + {
> + print $text;
> + }
> +
> + // }}}
> + // {{{ displayPlaintextRow()
> +
> + function displayPlaintextRow($title, $text = ' ')
> + {
> + print " <tr>\n";
> + print " <th align=\"right\"
> valign=\"top\">$title</th>";
> + print " <td>";
> + $this->displayPlaintext($text);
> + print "</td>\n";
> + print " </tr>\n";
> + }
> +
> + // }}}
>
> // {{{ returnText()
>
> @@ -747,6 +776,29 @@
> }
>
> // }}}
> + // {{{ returnPlaintext()
> +
> + function returnPlaintext($text = ' ')
> + {
> + return $text;
> + }
> +
> + // }}}
> + // {{{ returnPlaintextRow()
> +
> + function returnPlaintextRow($title, $text = ' ')
> + {
> + $str = " <tr>\n";
> + $str .= " <th align=\"right\">$title:</th>";
> + $str .= " <td>";
> + $str .= $this->returnPlaintext($text);
> + $str .= "</td>\n";
> + $str .= " </tr>\n";
> +
> + return $str;
> + }
> +
> + // }}}
>
> // {{{ display()
>
> @@ -798,6 +850,10 @@
> case "select":
> $params = 8;
> $defind = 4;
> + break;
> + case "plaintext":
> + $params = 2;
> + $defind = 1;
> break;
> default:
> // unknown field type
>
>
> Ted Shieh
> LiquidMarkets
> http://www.liquidmarkets.com
>
> _________________________________________________________________
> Chat with friends online, try MSN Messenger:
> http://messenger.msn.com
>
>
> --
> PEAR Development Mailing List (http://pear.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php