protected function _create($postdata = array())
    {
        if (!$this->is_create || $this->table_ro)
            return self::error('Forbidden');

        $this->primary_val = null;
        $this->result_row = array_merge($this->defaults, $postdata);

        if ($this->before_create)
        {
            $path = $this->check_file($this->before_create['path'], 'before_create');
            include_once ($path);
            if (is_callable($this->before_create['callable']))
            {
                $postdata = new Fruit_postdata($this->result_row, $this);
                call_user_func_array($this->before_create['callable'], array($postdata, $this));
                $this->result_row = $postdata->to_array();
            }
        }

        $this->_set_field_names();

        /** conditions process */
        if ($this->condition)
        {
            foreach ($this->condition as $params)
            {
                if (!isset($params['mode']['create']))
                    continue;

                $params['value'] = $this->replace_text_variables($params['value'], $this->result_row);
                if (array_key_exists($params['field'], $this->result_row) && $this->_compare($this->result_row[$params['field']], $params['operator'],
                    $params['value']))
                {
                    if (is_array($params['method']) && is_callable($params['method']))
                    {
                        call_user_func_array($params['method'], $params['params']);
                    }
                    elseif (is_callable(array($this, $params['method'])))
                    {
                        $this->condition_backup($params['method']);
                        call_user_func_array(array($this, $params['method']), $params['params']);
                    }
                    elseif (is_callable($params['method']))
                    {
                        call_user_func_array($params['method'], $params['params']);
                    }
                }
            }
        }
        return $this->_render_details('create');
    }
protected function _create($postdata = array())
    {
        if (!$this->is_create || $this->table_ro)
            return self::error('Forbidden');

        $this->primary_val = null;
        $this->result_row = array_merge($this->defaults, $postdata);

        if ($this->before_create)
        {
            $path = $this->check_file($this->before_create['path'], 'before_create');
            include_once ($path);
            if (is_callable($this->before_create['callable']))
            {
                $postdata = new Fruit_postdata($this->result_row, $this);
                call_user_func_array($this->before_create['callable'], array($postdata, $this));
                $this->result_row = $postdata->to_array();
            }
        }

        $this->_set_field_names();

        /** conditions process */
        if ($this->condition)
        {
            foreach ($this->condition as $params)
            {
                if (!isset($params['mode']['create']))
                    continue;

                $params['value'] = $this->replace_text_variables($params['value'], $this->result_row);
                if (array_key_exists($params['field'], $this->result_row) && $this->_compare($this->result_row[$params['field']], $params['operator'],
                    $params['value']))
                {
                    if (is_array($params['method']) && is_callable($params['method']))
                    {
                        call_user_func_array($params['method'], $params['params']);
                    }
                    elseif (is_callable(array($this, $params['method'])))
                    {
                        $this->condition_backup($params['method']);
                        call_user_func_array(array($this, $params['method']), $params['params']);
                    }
                    elseif (is_callable($params['method']))
                    {
                        call_user_func_array($params['method'], $params['params']);
                    }
                }
            }
        }
        return $this->_render_details('create');
    }
protected function _create ( $ postdata = array ( ) ) { if ( ! $ this -> is_create || $ this -> table_ro ) return self :: error ( 'Forbidden' ) ; $ this -> primary_val = null ; $ this -> result_row = array_merge ( $ this -> defaults , $ postdata ) ; if ( $ this -> before_create ) { $ path = $ this -> check_file ( $ this -> before_create [ 'path' ] , 'before_create' ) ; include_once ( $ path ) ; if ( is_callable ( $ this -> before_create [ 'callable' ] ) ) { $ postdata = new Fruit_postdata ( $ this -> result_row , $ this ) ; call_user_func_array ( $ this -> before_create [ 'callable' ] , array ( $ postdata , $ this ) ) ; $ this -> result_row = $ postdata -> to_array ( ) ; } } $ this -> _set_field_names ( ) ; /** conditions process */ if ( $ this -> condition ) { foreach ( $ this -> condition as $ params ) { if ( ! isset ( $ params [ 'mode' ] [ 'create' ] ) ) continue ; $ params [ 'value' ] = $ this -> replace_text_variables ( $ params [ 'value' ] , $ this -> result_row ) ; if ( array_key_exists ( $ params [ 'field' ] , $ this -> result_row ) && $ this -> _compare ( $ this -> result_row [ $ params [ 'field' ] ] , $ params [ 'operator' ] , $ params [ 'value' ] ) ) { if ( is_array ( $ params [ 'method' ] ) && is_callable ( $ params [ 'method' ] ) ) { call_user_func_array ( $ params [ 'method' ] , $ params [ 'params' ] ) ; } elseif ( is_callable ( array ( $ this , $ params [ 'method' ] ) ) ) { $ this -> condition_backup ( $ params [ 'method' ] ) ; call_user_func_array ( array ( $ this , $ params [ 'method' ] ) , $ params [ 'params' ] ) ; } elseif ( is_callable ( $ params [ 'method' ] ) ) { call_user_func_array ( $ params [ 'method' ] , $ params [ 'params' ] ) ; } } } } return $ this -> _render_details ( 'create' ) ; }
creates fieldlist for adding record
creates fieldlist for adding record