Ejemplo n.º 1
0
 function end($tag, $attributes, $cdata)
 {
     if (!$this->table) {
         return;
     }
     switch ($tag) {
         case 'row':
             if ($this->record && !$this->record->isLoaded()) {
                 $exist = false;
                 if ($fields = $this->record->getTable()->_checkUnique) {
                     $where = array();
                     foreach ($fields as $f) {
                         $where[$f] = isset($this->record->{$f}) ? $this->record->{$f} : null;
                     }
                     $records = $this->record->getTable()->findBy($where);
                     $exist = (bool) count($records);
                 }
                 if (!$exist) {
                     $this->record->insert();
                 }
             }
             $this->record = null;
             break;
         case 'field':
             if (!empty($this->record)) {
                 $this->record->set($attributes['name'], $cdata);
             }
             break;
     }
 }
 public function _valuesToForm(array &$values, Am_Record $record)
 {
     if ($record->isLoaded()) {
         $values['_category'] = $record->getCategories();
     }
     parent::_valuesToForm($values, $record);
 }