silverstripe-framework/forms/RestrictedTextField.php
Sam Minnee b1d2e3906b API Documentation updates
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@47766 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-01-09 04:18:36 +00:00

34 lines
1.1 KiB
PHP
Executable File

<?php
/**
* @package forms
* @subpackage fields-formatted
*/
/**
* A Text field that cannot contain certain characters
* @package forms
* @subpackage fields-formatted
*/
class RestrictedTextField extends TextField {
protected $restrictedChars;
function __construct($name, $title = null, $value = "", $restrictedChars = "", $maxLength = null){
$this->restrictedChars = $restrictedChars;
parent::__construct($name, $title, $value, $form);
}
function Field() {
Requirements::javascript( 'sapphire/javascript/UniqueFields.js' );
if($this->maxLength){
$field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" />";
}else{
$field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />";
}
return $field."<input type=\"hidden\" name=\"restricted-chars[".$this->id()."]\" id=\"".$this->id()."-restricted-chars\" value=\"".$this->restrictedChars."\" />";
}
}
?>