In order to provide for a unified user interface, BitOwl Application Suit provides functions in order to generate control panel forms.
The BitOwl_Form class encases all objects within a form.
BitOwl_Form::__construct([$buttons, [$location]])
Initializes the form. $buttons
specifies which actions
can be performed on the form. Valid values are BTN_SUBMIT
,
BTN_UPLOAD
, BTN_RESET
, and
BTN_PREVIEW
(use 0 for no buttons).
$location
allows the url in which the form posts to to be
specified explicity.
void BitOwl_Form::addMessage($message)
Adds a short message above the form.
BitOwl_FormGroup& BitOwl_Form::newGroup($name[, $css])
Creates a field set using the specified name. The $css
parameter allows additional css classes to be added.
void BitOwl_Form::printForm([$newButtons, $reset])
Prints the form. If the optional paremeters are used you may flush the forms current state and add more widgets under the original set of buttons.
A FormGroup holds a list of widgets to be printed. These are usually
constructed through BitOwl_Form::newGroup()
.
BitOwl_FormTable& BitOwl_FormGroup::newTable($header[, $rows])
Adds a table to the group with the specified header and table data. The header should be an array of strings and the rows should be a two dimensional array.
BitOwl_FormWidget& BitOwl_FormGroup::newWidget($type, $label[, $name[, $value[, $options]]])
Constructs a new form widget and adds it to the group.
Represents a single form widget. They may be constructed directly for use in
tables, however in general they will be constructed through BitOwl_FormGroup::newWidget()
.
Valid types and their descriptions are as follows:
LABEL
Simply prints the input to the screen. You may specify both a label and value or just a label.
TEXT
and LONGTEXT
and PASSWORD
Single line text input.
MULTILINE
and STORYBOX
Multiline text input. Story box provides a larger viewable space.
COMBOBOX
and SELECTION
Handles input with predetermined values. $options
should be an array in the format of array('id' => x, 'name' => y)
.
For a selection the value must be such that $value[$id]
is true.
UPLOAD
File upload.
PAGINATION
Prints the pagination object in the $value
field.
HIDDEN
Form widget that provides unchangable information.
A FormTable is a type of FormWidget which represents a table. Rows may contain either strings or FormWidget objects.
void BitOwl_FormTable::addRow($row)
Adds a single row to the end of the table.
File uploads can be handled easily with the help of the BitOwl_Upload class.
BitOwl_Upload::__construct($file)
Pass in the name of the file input field.
void BitOwl_Upload::delete()
Deletes the uploaded file, useful if a problem is detected in the file (for example if an image is expected and a text file was given instead).
str BitOwl_Upload::getDestination()
Returns the final filename (with meta data intact) of the file after uploading.
str BitOwl_Upload::getName()
Either returns the name of the file uploaded or the meta data stripped name of the final filename (which in most cases will be the same).
int BitOwl_Upload::getStatus()
Returns either BitOwl_Upload::UPLOAD_BAD, BitOwl_Upload::UPLOAD_OK, or BitOwl_Upload::UPLOAD_TOOBIG.
str BitOwl_Upload::getType()
Returns the mime type of the file.
bool BitOwl_Upload::isUploaded()
Returns true if the upload method was successful.
str BitOwl_Upload::stripFilename($file) [static]
Returns the filename with any meta data stripped.
str BitOwl_Upload::makeFilename($file) [static]
Prepends meta data to the input filename.
str BitOwl_Upload::upload([$destination[, $maxsize]])
Moves the uploaded file to its final destination setting the status on failure.