本文整理汇总了PHP中StringField::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP StringField::__construct方法的具体用法?PHP StringField::__construct怎么用?PHP StringField::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringField
的用法示例。
在下文中一共展示了StringField::__construct方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* {@inheritdoc}
*/
public function __construct($name, $default_value = null, $add_index = false)
{
parent::__construct($name, $default_value, $add_index);
if ($default_value !== null) {
$this->modifier('trim');
}
}
示例2: __construct
/**
* {@inheritdoc}
*/
public function __construct($name = 'country_code', $default_value = null, $add_index = false)
{
parent::__construct($name, $default_value, $add_index);
if ($default_value !== null) {
$this->modifier('strtoupper');
}
$this->length(2);
}
示例3: __construct
/**
* Create a new Enum field.
*
* Example usage in {@link DataObject::$db} with comma-separated string
* notation ('Val1' is default)
*
* <code>
* "MyField" => "Enum('Val1, Val2, Val3', 'Val1')"
* </code>
*
* Example usage in in {@link DataObject::$db} with array notation
* ('Val1' is default)
*
* <code>
* "MyField" => "Enum(array('Val1', 'Val2', 'Val3'), 'Val1')"
* </code>
*
* @param enum: A string containing a comma separated list of options or an
* array of Vals.
* @param string The default option, which is either NULL or one of the
* items in the enumeration.
*/
public function __construct($name = null, $enum = NULL, $default = NULL)
{
if ($enum) {
$this->setEnum($enum);
// If there's a default, then
if ($default) {
if (in_array($default, $this->getEnum())) {
$this->setDefault($default);
} else {
user_error("Enum::__construct() The default value '{$default}' does not match any item in the" . " enumeration", E_USER_ERROR);
}
// By default, set the default value to the first item
} else {
$enum = $this->getEnum();
$this->setDefault(reset($enum));
}
}
parent::__construct($name);
}
示例4: __construct
/**
* Create a new Enum field.
*
* Example usage in {@link DataObject::$db} with comma-separated string
* notation ('Val1' is default)
*
* <code>
* "MyField" => "Enum('Val1, Val2, Val3', 'Val1')"
* </code>
*
* Example usage in in {@link DataObject::$db} with array notation
* ('Val1' is default)
*
* <code>
* "MyField" => "Enum(array('Val1', 'Val2', 'Val3'), 'Val1')"
* </code>
*
* @param enum: A string containing a comma separated list of options or an
* array of Vals.
* @param string The default option, which is either NULL or one of the
* items in the enumeration.
*/
public function __construct($name = null, $enum = NULL, $default = NULL)
{
if ($enum) {
if (!is_array($enum)) {
$enum = preg_split("/\\s*,\\s*/", trim($enum, ", \t\n\r\v"));
}
$this->enum = $enum;
// If there's a default, then
if ($default) {
if (in_array($default, $enum)) {
$this->default = $default;
} else {
user_error("Enum::__construct() The default value '{$default}' does not match any item in the" . " enumeration", E_USER_ERROR);
}
// By default, set the default value to the first item
} else {
$this->default = reset($enum);
}
}
parent::__construct($name);
}
示例5: __construct
/**
* EmailField constructor.
*/
public function __construct()
{
parent::__construct();
$this->addValidationRules(['email']);
}
示例6: __construct
public function __construct($name, $object = null)
{
$this->object = $object;
parent::__construct($name);
}
示例7: __construct
/**
* Construct a new short text field
*
* @param $name string The name of the field
* @param $size int The maximum size of the field, in terms of characters
* @param $options array Optional parameters, e.g. array("nullifyEmpty"=>false).
* See {@link StringField::setOptions()} for information on the available options
* @return unknown_type
*/
public function __construct($name = null, $size = 50, $options = array())
{
$this->size = $size ? $size : 50;
parent::__construct($name, $options);
}
示例8: array
function __construct($name, $parameters = array())
{
parent::__construct($name, $parameters);
$this->dataType = $this->fieldType = 'text';
}
示例9: __construct
public function __construct($label, $validators = [], $options = [])
{
parent::__construct($label, $validators, $options);
$this->type = 'password';
}
示例10: __construct
/**
* Create a field object.
* @param string $label - Label for the field.
* @uses WTForms\Widgets\TextAreaWidget
*/
public function __construct($label, $validators = [], $options = [])
{
parent::__construct($label, $validators, $options);
$this->widget = new TextAreaWidget();
$this->type = 'textarea';
}
示例11:
function __construct(array $args)
{
parent::__construct($args);
$this->type = 'hidden';
}