silverstripe-framework/forms/TextField.php
Ingo Schommer b08dba9173 Merged revisions 47505 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq

........
  r47505 | ischommer | 2007-12-22 17:31:58 +1300 (Sat, 22 Dec 2007) | 1 line
  
  fixed maxlength mixups
........


git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@52190 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-04-06 04:02:39 +00:00

45 lines
1.0 KiB
PHP
Executable File

<?php
/**
* @package forms
* @subpackage fields-basic
*/
/**
* Text input field.
* @package forms
* @subpackage fields-basic
*/
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() {
$attributes = array(
'type' => 'text',
'class' => $this->extraClass() . ' text',
'id' => $this->id(),
'name' => $this->attrName(),
'value' => $this->attrValue(),
'tabindex' => $this->getTabIndex(),
'maxlength' => ($this->maxLength) ? $this->maxLength : null,
'size' => ($this->maxLength) ? min( $this->maxLength, 30 ) : null
);
return $this->createTag('input', $attributes);
}
function InternallyLabelledField() {
if(!$this->value) $this->value = $this->Title();
return $this->Field();
}
}
?>