Version: current

     1 <?php
     2 /**
     3  * A Text field that cannot contain certain characters
     4  * @deprecated 2.5
     5  * @package forms
     6  * @subpackage fields-formatted
     7  */
     8 class RestrictedTextField extends TextField {
     9
    10     protected $restrictedChars;
    11
    12     function __construct($name, $title = null, $value = "", $restrictedChars = "", $maxLength = null){
    13         $this->restrictedChars = $restrictedChars;
    14         parent::__construct($name, $title, $value);
    15     }
    16
    17     function Field() {
    18         Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
    19         Requirements::javascript( SAPPHIRE_DIR . '/javascript/UniqueFields.js' );
    20
    21         if($this->maxLength){
    22             $field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" maxlength=\"$this->maxLength\" />";
    23         }else{
    24             $field = "<input class=\"text restricted\" type=\"text\" id=\"" . $this->id() . "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" />";
    25         }
    26
    27         return $field."<input type=\"hidden\" name=\"restricted-chars[".$this->id()."]\" id=\"".$this->id()."-restricted-chars\" value=\"".$this->restrictedChars."\" />";
    28     }
    29 }
    30 ?>

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -