Ejemplo n.º 1
0
 /**
  * Adds a trim filter if it doesn't already exist.
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  **/
 public function initialize($model, $column)
 {
     parent::initialize($model, $column);
     if ($this->trim) {
         $this->filters += array($this->null ? 'Field_String::trim' : 'trim' => null);
     }
 }
Ejemplo n.º 2
0
 /**
  * Selects the default value from the choices if NULLs are not allowed, but
  * the given value is NULL.
  *
  * This is intended to mimic the way MySQL selects the default value if
  * nothing is given.
  *
  * @param   mixed  $value
  * @return  string
  */
 public function set($value)
 {
     if ($value === NULL and !$this->allow_null) {
         // Set value to the default value
         $value = $this->default;
     }
     return parent::set($value);
 }
Ejemplo n.º 3
0
 /**
  * Adds an email validation rule if it doesn't already exist.
  *
  * @param   string  $model
  * @param   string  $column
  * @return  void
  **/
 public function initialize($model, $column)
 {
     parent::initialize($model, $column);
     if (count($this->rules) > 0) {
         // If rules can be found check if the rule for e-mail is set
         foreach ($this->rules as $rule) {
             if (is_string($rule[0]) and $rule[0] === 'email') {
                 // E-mail rule is set no need to continue
                 return;
             }
         }
     }
     // Add the rule for e-mail
     $this->rules[] = array('email');
 }
Ejemplo n.º 4
0
 /**
  * Adds a filter that hashes the password.
  *
  * @param   Jelly_Model  $model
  * @param   mixed        $column
  * @return  void
  */
 public function initialize($model, $column)
 {
     parent::initialize($model, $column);
     // Add a filter that hashes the password when validating
     $this->filters[] = array(array(':field', 'hash'), array(':value', ':model'));
 }