PEAR Manual
Prev |  | Next

# HTML_QuickForm::createElement()

HTML_QuickForm::createElement() -- Creates a new form element of the given type

## Synopsis

    require_once 'HTML/QuickForm.php';

``object &HTML_QuickForm::createElement` (string $elementType)`

## Description

Creates a new form element of the given type. This method accepts variable number of parameters, their meaning and count depending on `$elementType`.

Parameters starting from second will be passed to the element's constructor, consult the docs for the appropriate element to find out which parameters to pass.

## Parameter

string `$elementType`

  type of element to create (text, textarea, file...)

## Return value

return object, descendant of HTML_QuickForm_element

## Throws

Table 41-1. Possible PEAR_Error values

Error code | Error message | Reason | Solution
--- | --- | --- | ---
`QUICKFORM_UNREGISTERED_ELEMENT` | Element '`$element`' does not exist in HTML_QuickForm::_loadElement() | Tried to create an element of unknown type | Check the type name spelling or use HTML_QuickForm::registerElementType()

## Note

since 1.0

This function can be called statically.

Prev | Home | Next
HTML_QuickForm::apiVersion() | Up | HTML_QuickForm::elementExists()