diff --git a/Editor.php b/Editor.php index c62d048..f3169f2 100644 --- a/Editor.php +++ b/Editor.php @@ -1890,18 +1890,16 @@ private function _ssp_filter($query, $http) }); } - /* - foreach ($this->_fields as $field) { - // Don't reselect a pkey column if it was already added - if ( in_array( $field->dbField(), $this->_pkey ) ) { - continue; - } - - if ( $field->apply('get') && $field->getValue() === null ) { - $query->get( $field->dbField() ); - } - } - */ + // foreach ($this->_fields as $field) { + // // Don't reselect a pkey column if it was already added + // if ( in_array( $field->dbField(), $this->_pkey ) ) { + // continue; + // } + + // if ( $field->apply('get') && $field->getValue() === null ) { + // $query->get( $field->dbField() ); + // } + // } if (isset($http['searchPanes'])) { // Set the database from editor @@ -1919,14 +1917,18 @@ private function _ssp_filter($query, $http) $q->left_join($this->_leftJoin); // ... where the selected option is present... - $r = $q - ->where( + if (isset($http['searchPanes_null'][$field->name()][$i]) && $http['searchPanes_null'][$field->name()][$i] === 'true') { + $q->where($field->dbField(), null, '='); + } + else { + $q->where( $field->dbField(), - isset($http['searchPanes_null'][$field->name()][$i]) && $http['searchPanes_null'][$field->name()][$i] === 'true' - ? null - : $http['searchPanes'][$field->name()][$i], + $http['searchPanes'][$field->name()][$i], '=' - ) + ); + } + + $r = $q ->exec() ->fetchAll(); @@ -1942,8 +1944,8 @@ private function _ssp_filter($query, $http) $q->or_where( $field->dbField(), isset($http['searchPanes_null'][$field->name()][$j]) && $http['searchPanes_null'][$field->name()][$j] === 'true' - ? null - : $http['searchPanes'][$field->name()][$j], + ? null + : $http['searchPanes'][$field->name()][$j], '=' ); } @@ -2073,9 +2075,7 @@ private function _insert_or_update($id, $values) $res = $this->_insert_or_update_table( $this->_table[$i], $values, - $id !== null ? - $this->pkeyToArray($id, true) : - null + $id !== null ? $this->pkeyToArray($id, true) : null ); // If we don't have an id yet, then the first insert will return @@ -2244,17 +2244,17 @@ private function _options($refresh) if ($options) { $opts = $options($this->_db, $refresh); - + if ($opts !== false) { if (!isset($this->_out['options'])) { $this->_out['options'] = []; } - + $this->_out['options'][$field->name()] = $opts; } } - if (! $refresh) { + if (!$refresh) { // SearchPanes options $spOpts = $field->searchPaneOptionsExec($field, $this, $this->_processData, $this->_fields, $this->_leftJoin); diff --git a/Editor/Field.php b/Editor/Field.php index b991b7f..4a18b56 100644 --- a/Editor/Field.php +++ b/Editor/Field.php @@ -574,11 +574,13 @@ public function apply($action, $data = null) // Note that validation must be done on input data before we get here // Create or edit action, are we configured to use this field - if ($action === 'create' + if ( + $action === 'create' && ($this->_set === Field::SET_NONE || $this->_set === Field::SET_EDIT) ) { return false; - } elseif ($action === 'edit' + } elseif ( + $action === 'edit' && ($this->_set === Field::SET_NONE || $this->_set === Field::SET_CREATE) ) { return false;