Forms

Please note: This page is under construction and has not been finished yet.

Introduction

Use the following to retrieve the form class object

$frm = e107::getForm();

Forms methods

open()

Returns a form opening tag.

$frm->open('myform'); 
$frm->open('myform', 'get', 'myscript.php', array('autocomplete' => 'on', 'class' => 'formclass'));

close()

Returns a form closing tag

$frm->close();

text()

Returns a text field form element

$frm->text('my-field', 'current_value', 100, array('size' => 'large')); // returns <input class="tbox input-large" id="my-field" maxlength="100" name="my-field" type="text" value="current_value"></input>

textarea()

$frm->textarea($name, $value, $rows, $cols, $options, $counter);

bbarea()

$frm->bbarea($name, $value, $template, $mediaCat, $size, $options);

select()

$frm->select($name,$option_array,$selected,$options,$defaultBlank);

checkbox()

$frm->checkbox($name,$value,$checked,$options);

hidden()

$frm->hidden($name,$value,$options);

button()

$frm->button($name,$value,$action,$label,$options);

Render a Bootstrap carousel

$frm->carousel($name, $array, $options);
$array = array(
      'slide1' => array('caption' => 'Slide 1', 'text' => 'first slide content' ),
      'slide2' => array('caption' => 'Slide 2', 'text' => 'second slide content' ),
      'slide3' => array('caption' => 'Slide 3', 'text' => 'third slide content' )
  );

echo $frm->carousel('my-carousel', $array);

tabs()

Render Bootstrap tabs

$frm->tabs($array,$options);
$array = array(
   'home'  => array('caption' => 'Home', 'text' => 'some tab content' ),
   'other' => array('caption' => 'Other', 'text' => 'second tab content' )
);

echo $frm->tabs($array);

echo $frm->tabs($array, array('active' => 'other')); // make 'other' the initial active tab. 

datepicker()

Date field with popup calendar. Returns UNIX timestamp or string value on submit.

$frm->datepicker($name, $datestamp = false, $options = null)

TODO: Clarify possible options and add more examples

Examples:

$frm->datepicker('my_field',time(),'mode=date');
$frm->datepicker('my_field',time(),'mode=datetime&inline=1');
$frm->datepicker('my_field',time(),'mode=date&format=yyyy-mm-dd');
$frm->datepicker('my_field',time(),'mode=datetime&format=MM, dd, yyyy hh:ii');
$frm->datepicker('my_field',time(),'mode=datetime&return=string');

Last updated