Manual

field.class.php

Static functions for building forms, no initialization needed. All functions have 3 parameters:

Field::type($name, $value[, $extra=array()])

Usage:

{{lang:php}}
// USAGE
$name = 'company';
$value = 'Editor'
$extra = array('class'=>'field','maxlength'=>'50');
echo Field::text($name, $value, $extra);

// returns 
// <input type="text" name="company" value="Editor" class="field" maxlength="50"/>

echo Field::hidden('id', '25');

// returns
// <input type="hidden" name="company" value="25"/>

echo Field::textarea('comment', '', array('id'=>'comment','cols'=>'30','rows'=>'5'));

// returns
// <textarea id="comment" cols="30" rows="5"></textarea>

// MORE EXAMPLES
echo Field::radio('gender', 'm', array('checked'=>1));
echo Field::checkbox('agree', '1', array('checked'=>0));

echo Field::password($name, $value, $extra);
echo Field::file($name, $value, $extra);
echo Field::button($name, $value, $extra);
echo Field::reset($name, $value, $extra);
echo Field::submit($name, $value, $extra);

// COMPLEX EXAMPLES
$cars = array(
    array('value'=>1,'name'=>'Opel'),
    array('value'=>2,'name'=>'Volvo'),
    array('value'=>3,'name'=>'Audi'),
    array('value'=>4,'name'=>'Mercedes'),
    array('value'=>5,'name'=>'Seat')
);
echo Field::select('car',2,array('data'=>$cars));

// returns
/*
    <select name="car">
        <option value=""></option>
        <option value="1">Opel</option>
        <option value="2" selected="selected" >Volvo</option>
        <option value="3">Audi</option>
        <option value="4">Mercedes</option>
        <option value="5">Seat</option>
    </select>
*/

// eliminate the first (empty) line
echo Field::select('car',2,array('data'=>$cars, 'noempty'=>1));

//

echo Field::multiselect('car[]',array(2,3),array('data'=>$cars));

//returns
/* 
    <label><input type="checkbox" value="1" name="car[]"/> Opel</label>
    <label><input type="checkbox" value="2" name="car[]" checked="checked"/> Volvo</label>
    <label><input type="checkbox" value="3" name="car[]" checked="checked"/> Audi</label>
    <label><input type="checkbox" value="4" name="car[]"/> Mercedes</label>
    <label><input type="checkbox" value="5" name="car[]"/> Seat</label>
*/
Try myPortal 2: