/**
  * {@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');
     }
 }
 /**
  * {@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);
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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);
 }
Example #5
0
 /**
  * EmailField constructor.
  */
 public function __construct()
 {
     parent::__construct();
     $this->addValidationRules(['email']);
 }
 public function __construct($name, $object = null)
 {
     $this->object = $object;
     parent::__construct($name);
 }
Example #7
0
 /**
  * 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);
 }
Example #8
0
 function __construct($name, $parameters = array())
 {
     parent::__construct($name, $parameters);
     $this->dataType = $this->fieldType = 'text';
 }
Example #9
0
 public function __construct($label, $validators = [], $options = [])
 {
     parent::__construct($label, $validators, $options);
     $this->type = 'password';
 }
Example #10
0
 /**
  * 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';
 }
 function __construct(array $args)
 {
     parent::__construct($args);
     $this->type = 'hidden';
 }