epnadmin-fr
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Epnadmin-fr] Re: document Pear_HTML


From: Loïc Dayot
Subject: [Epnadmin-fr] Re: document Pear_HTML
Date: Fri, 09 Sep 2005 14:27:32 +0200
User-agent: Mozilla Thunderbird 1.0.2 (X11/20050322)

Ca me parait très bien tout ça.
Et c'est déjà dans includes/pear/HTML ? ou il faut installer pear ?
Cela dit, on peut très bien imposer un jour ou l'aute l'usage de pear qui se répend...
Loïc.


Marc C a écrit :
document PEAR_HTML

cvs update -dPA 2> /dev/null

 2fois
  



wiki_noodle - Tutorials Pear Html Form

HTML_Form is a Pear class that allow you to build HTML Form writing less HTML.

We'll explain trough different examples how to use this class.

The basics

A form is consist of different type of input : text, select, textarea, checkbox, radio button, hidden field

W3C Definition

Quick sample :

<form>

<input type="text" name="input_name" value="input_default_value">

<select name="select_name">
   <option>value 1</option>
   <option>value 2</option>
</select>

<textarea name="textarea_name">
default value
</textarea>

</form>

The problem

Too many times when writing php form you do :

echo '<input type="text" name="variable_name" value="'.$default_value.'">";


foreach($options as $option) {
   echo '<input type="text" name="option'.$option->name.'?" value="'.$option->value.'">";
}

The solution

PEAR::HTML_Form, no other PEAR dependency, it allow you to build simple form without writing any HTML code, just use the 'add' method then display the form or call directly the methods.

A quick table form, with 2 columns :

require 'HTML/Form.php';

$form = new HTML_Form('HTML_Form.php','post');
$form->addText('text_name', 'text title :');
$form->addTextarea('textarea_name', 'textarea title : ');
$choices = array(1,2,3,4,5,6);
$form->addSelect('select_name', 'select title : ', $choices);
$form->addSubmit('submit');
$form->display();

Another way of using it, calling directly the methods :

echo HTML_Form::returnSelect('select_name', $choices);
// OR
$output_variable = $message . HTML_Form::returnSubmit('submit') . $end_of_page;

Tips

If you want to add some _javascript_ here is how to do it :

$form->addText('text_name"  class="moz-txt-link-rfc2396E" href="">"_javascript_:js_action()', 'text title :');
// OR
$variable = HTML_Form::returnSubmit('submit" footer">
  

Last edited on Monday, September 5, 2005 12:37:15 pm.


Edit PageHistory Diff PageInfo
 Sign in:


-- 
Loïc Dayot
--------------------
Chargé de mission Technologies de l'information et de la communication
Mairie de Pierrefitte-sur-Seine
Tél. 01 72 09 34 43 - Cell. 06 16 35 05 07 - Fax 01 72 09 34 48
Hôtel de ville - 2, place de la Libération - 93380 Pierrefitte-sur-Seine
http://www.pierrefitte93.fr

reply via email to

[Prev in Thread] Current Thread [Next in Thread]