2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Text input field.
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-basic
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class TextField extends FormField {
|
|
|
|
protected $maxLength;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an input field, class="text" and type="text" with an optional maxlength
|
|
|
|
*/
|
|
|
|
function __construct($name, $title = null, $value = "", $maxLength = null, $form = null){
|
|
|
|
$this->maxLength = $maxLength;
|
|
|
|
parent::__construct($name, $title, $value, $form);
|
|
|
|
}
|
|
|
|
|
|
|
|
function Field() {
|
2008-04-06 06:02:05 +02:00
|
|
|
$attributes = array(
|
|
|
|
'type' => 'text',
|
2008-04-06 06:02:39 +02:00
|
|
|
'class' => $this->extraClass() . ' text',
|
2008-04-06 06:02:05 +02:00
|
|
|
'id' => $this->id(),
|
2008-04-09 13:21:22 +02:00
|
|
|
'name' => $this->Name(),
|
|
|
|
'value' => $this->Value(),
|
2008-04-06 06:02:21 +02:00
|
|
|
'tabindex' => $this->getTabIndex(),
|
2008-04-06 06:02:05 +02:00
|
|
|
'maxlength' => ($this->maxLength) ? $this->maxLength : null,
|
2008-04-06 06:02:39 +02:00
|
|
|
'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null
|
2008-04-06 06:02:05 +02:00
|
|
|
);
|
2007-07-19 12:40:28 +02:00
|
|
|
|
2008-10-20 12:18:25 +02:00
|
|
|
if($this->disabled) $attributes['disabled'] = 'disabled';
|
|
|
|
|
2008-04-06 06:02:05 +02:00
|
|
|
return $this->createTag('input', $attributes);
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function InternallyLabelledField() {
|
|
|
|
if(!$this->value) $this->value = $this->Title();
|
|
|
|
return $this->Field();
|
|
|
|
}
|
2008-08-06 04:43:46 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
}
|
2008-08-06 04:43:46 +02:00
|
|
|
?>
|