Beispiel #1
0
 public function beforeSave()
 {
     if (!empty($this->data['senha'])) {
         $cript = new \Core\Security();
         $this->data['senha'] = $cript->crypt($this->data['senha']);
     } else {
         unset($this->data['senha']);
     }
     //$this->data['username'] = $this->removeMask($this->data['username']);
 }
Beispiel #2
0
 public function beforeSave()
 {
     if (!empty($this->data['senha'])) {
         $cript = new \Core\Security();
         $this->data['senha'] = $cript->crypt($this->data['senha']);
     } else {
         unset($this->data['senha']);
     }
     $this->data['cpf'] = str_replace(['.', '-'], '', $this->data['cpf']);
     $this->data['email'] = strtolower($this->data['email']);
 }
Beispiel #3
0
 /**
  * Get provided field's linked table if it exists
  * @param string $field The field identifier/name
  * @return string The linked table 
  */
 public static final function getLinkedTable($field)
 {
     if (!self::isLinked($field)) {
         throw new Exception('Field [' . Core\Security::preventInjection($field) . '] is not linked, unable to get table.', E_WARNING, self::getClass());
     }
     $model = self::getField($field)->getModel();
     return $model::getTable();
 }
Beispiel #4
0
 /**
  * Add a new field from model to current form.
  * Similiar to add() but getting its field object from provided model based on field binding.
  * @param string $field
  * @param mixed $value
  */
 public function &addField($fieldname, $value = null)
 {
     if ($this->model == null) {
         throw new Exception('You need to provide a correct Orion\\Core\\Model before using addField()', E_WARNING, get_class($this));
     }
     if (array_key_exists($fieldname, $this->fields)) {
         throw new Exception('Duplicate field [' . Core\Security::preventInjection($fieldname) . '] during form creation.', E_WARNING, get_class($this));
     }
     $model = $this->model;
     if (!$model::hasField($fieldname)) {
         throw new Exception('The field [' . Core\Security::preventInjection($fieldname) . '] does not exist in provided model.', E_WARNING, get_class($this));
     }
     $this->fields[$fieldname] = $model::getField($fieldname);
     if ($value != null) {
         $this->fields[$fieldname]->setValue($value);
     }
     $this->indexes[] = $fieldname;
     return $this;
 }