form_textfield
Definition
form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL, $required = FALSE)
includes/common.inc, line 1222
Description
Format a single-line text field.
Parameters
$title The label for the text field.
$name The internal name used to refer to the field.
$value The initial value for the field at page load time.
$size A measure of the visible size of the field (passed directly to HTML).
$maxlength The maximum number of characters that may be entered in the field.
$description Explanatory text to display after the form item.
$attributes An associative array of HTML attributes to add to the form item.
$required Whether the user must enter some text in the field.
Return value
A themed HTML string representing the field.
Related topics
| Name | Description |
|---|---|
| Form generation | Functions to enable output of HTML forms and form elements. |
| Input validation | Functions to validate user input. |
Code
<?php
function form_textfield($title, $name, $value, $size, $maxlength, $description = NULL, $attributes = NULL, $required = FALSE) {
$size = $size ? ' size="'. $size .'"' : '';
return theme('form_element', $title, '<input type="text" maxlength="'. $maxlength .'" class="'. _form_get_class('form-text', $required, _form_get_error($name)) .'" name="edit['. $name .']" id="edit-'. $name .'"'. $size .' value="'. check_plain($value) .'"'. drupal_attributes($attributes) .' />', $description, 'edit-'. $name, $required, _form_get_error($name));
}
?> 