src/CRUD.php
public function initCreate()
    {
        // setting itemCreate manually is possible.
        if (!$this->itemCreate) {
            $this->itemCreate = $this->menu->addItem($this->itemCreate ?: ['Add new', 'icon' => 'plus']);
            $this->itemCreate->on('click.atk_CRUD', new jsModal('Add new', $this->pageCreate, [$this->name.'_sort' => $this->getSortBy()]));
            $this->itemCreate->set('Add New '.$this->model->getModelCaption());
        }

        // setting callback for the page
        $this->pageCreate->set(function () {

            // formCreate may already be an object added inside pageCreate
            if (!is_object($this->formCreate) || !$this->formCreate->_initialized) {
                $this->formCreate = $this->pageCreate->add($this->formCreate ?: $this->formDefault);
            }

            // $form = $page->add($this->formCreate ?: ['Form', 'layout' => 'FormLayout/Columns']);
            $this->formCreate->setModel($this->model, $this->fieldsCreate ?: $this->fieldsDefault);

            if ($sortBy = $this->getSortBy()) {
                $this->formCreate->stickyGet($this->name.'_sort', $sortBy);
            }

            // set save handler with reload trigger
            // adds default submit hook if it is not already set for this form
            if (!$this->formCreate->hookHasCallbacks('submit')) {
                $this->formCreate->onSubmit(function ($form) {
                    $form->model->save();

                    return $this->jsSaveCreate();
                });
            }
        });
    }
public function initCreate()
    {
        // setting itemCreate manually is possible.
        if (!$this->itemCreate) {
            $this->itemCreate = $this->menu->addItem($this->itemCreate ?: ['Add new', 'icon' => 'plus']);
            $this->itemCreate->on('click.atk_CRUD', new jsModal('Add new', $this->pageCreate, [$this->name.'_sort' => $this->getSortBy()]));
            $this->itemCreate->set('Add New '.$this->model->getModelCaption());
        }

        // setting callback for the page
        $this->pageCreate->set(function () {

            // formCreate may already be an object added inside pageCreate
            if (!is_object($this->formCreate) || !$this->formCreate->_initialized) {
                $this->formCreate = $this->pageCreate->add($this->formCreate ?: $this->formDefault);
            }

            // $form = $page->add($this->formCreate ?: ['Form', 'layout' => 'FormLayout/Columns']);
            $this->formCreate->setModel($this->model, $this->fieldsCreate ?: $this->fieldsDefault);

            if ($sortBy = $this->getSortBy()) {
                $this->formCreate->stickyGet($this->name.'_sort', $sortBy);
            }

            // set save handler with reload trigger
            // adds default submit hook if it is not already set for this form
            if (!$this->formCreate->hookHasCallbacks('submit')) {
                $this->formCreate->onSubmit(function ($form) {
                    $form->model->save();

                    return $this->jsSaveCreate();
                });
            }
        });
    }
public function initCreate ( ) { // setting itemCreate manually is possible. if ( ! $ this -> itemCreate ) { $ this -> itemCreate = $ this -> menu -> addItem ( $ this -> itemCreate ? : [ 'Add new' , 'icon' => 'plus' ] ) ; $ this -> itemCreate -> on ( 'click.atk_CRUD' , new jsModal ( 'Add new' , $ this -> pageCreate , [ $ this -> name . '_sort' => $ this -> getSortBy ( ) ] ) ) ; $ this -> itemCreate -> set ( 'Add New ' . $ this -> model -> getModelCaption ( ) ) ; } // setting callback for the page $ this -> pageCreate -> set ( function ( ) { // formCreate may already be an object added inside pageCreate if ( ! is_object ( $ this -> formCreate ) || ! $ this -> formCreate -> _initialized ) { $ this -> formCreate = $ this -> pageCreate -> add ( $ this -> formCreate ? : $ this -> formDefault ) ; } // $form = $page->add($this->formCreate ?: ['Form', 'layout' => 'FormLayout/Columns']); $ this -> formCreate -> setModel ( $ this -> model , $ this -> fieldsCreate ? : $ this -> fieldsDefault ) ; if ( $ sortBy = $ this -> getSortBy ( ) ) { $ this -> formCreate -> stickyGet ( $ this -> name . '_sort' , $ sortBy ) ; } // set save handler with reload trigger // adds default submit hook if it is not already set for this form if ( ! $ this -> formCreate -> hookHasCallbacks ( 'submit' ) ) { $ this -> formCreate -> onSubmit ( function ( $ form ) { $ form -> model -> save ( ) ; return $ this -> jsSaveCreate ( ) ; } ) ; } } ) ; }
Initializes interface elements for new record creation.

@return array|jsExpression
Initializes interface elements for new record creation .