mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR: reverted r93693 due to the field being required for the CMS (from r93701)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@93938 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1345dd3e62
commit
3216c96a69
30
forms/RestrictedTextField.php
Executable file
30
forms/RestrictedTextField.php
Executable file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* A Text field that cannot contain certain characters
|
||||||
|
* @deprecated 2.3
|
||||||
|
* @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);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Field() {
|
||||||
|
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||||
|
Requirements::javascript( SAPPHIRE_DIR . '/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."\" />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
27
forms/UniqueRestrictedTextField.php
Executable file
27
forms/UniqueRestrictedTextField.php
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Text field that automatically checks that the value entered is unique for the given
|
||||||
|
* set of fields in a given set of tables
|
||||||
|
* @deprecated 2.3
|
||||||
|
* @package forms
|
||||||
|
* @subpackage fields-formattedinput
|
||||||
|
*/
|
||||||
|
class UniqueRestrictedTextField extends UniqueTextField {
|
||||||
|
|
||||||
|
protected $charRegex;
|
||||||
|
protected $charReplacement;
|
||||||
|
protected $charMessage;
|
||||||
|
|
||||||
|
function __construct($name, $restrictedField, $restrictedTable, $restrictedMessage, $charRegex, $charReplacement, $charMessage, $title = null, $value = "", $maxLength = null ){
|
||||||
|
$this->charRegex = $charRegex;
|
||||||
|
$this->charReplacement = $charReplacement;
|
||||||
|
$this->charMessage = $charMessage;
|
||||||
|
|
||||||
|
parent::__construct($name, $restrictedField, $restrictedTable, $restrictedMessage, $title, $value, $maxLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Field() {
|
||||||
|
return parent::Field()."<input type=\"hidden\" name=\"restricted-chars[".$this->id()."]\" id=\"".$this->id()."-restricted-chars\" value=\"".$this->charRegex."\" /><input type=\"hidden\" name=\"restricted-chars[".$this->id()."]\" id=\"".$this->id()."-restricted-chars-replace\" value=\"".$this->charReplacement."\" /><input type=\"hidden\" name=\"restricted-chars[".$this->id()."]\" id=\"".$this->id()."-restricted-chars-message\" value=\"".$this->charMessage."\" />";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
Loading…
Reference in New Issue
Block a user