View_CRUD::isEditing PHP Method

isEditing() public method

Returns if CRUD is in editing mode or not. It's preferable over checking if($grid->form).
public isEditing ( string $mode = null ) : boolean
$mode string Specify which editing mode you expect
return boolean true if editing.
    public function isEditing($mode = null)
    {
        $page_mode = $this->virtual_page->isActive();
        // Requested edit, but not allowed
        if ($page_mode == 'edit' && !$this->allow_edit) {
            throw $this->exception('Editing is not allowed');
        }
        // Requested add but not allowed
        if ($page_mode == 'add' && !$this->allow_add) {
            throw $this->exception('Adding is not allowed');
        }
        // Request matched argument exactly
        if (!is_null($mode)) {
            return $mode === $page_mode;
        }
        // Argument was blank, then edit/add is OK
        return (bool) $page_mode;
    }