FOF30\Controller\DataController::add PHP Метод

add() публичный Метод

Single record add. The form layout is used to present a blank page.
public add ( ) : void
Результат void
    public function add()
    {
        // Load and reset the model
        $model = $this->getModel()->savestate(false);
        $model->reset();
        // Set the layout to form, if it's not set in the URL
        if (empty($this->layout)) {
            $this->layout = 'form';
        } elseif ($this->layout == 'default') {
            $this->layout = 'form';
        }
        if (!empty($this->defaultsForAdd)) {
            $model->bind($this->defaultsForAdd);
        }
        // Get temporary data from the session, set if the save failed and we're redirected back here
        $sessionKey = $this->viewName . '.savedata';
        $itemData = $this->container->session->get($sessionKey, null, $this->container->componentName);
        $this->container->session->set($sessionKey, null, $this->container->componentName);
        if (!empty($itemData)) {
            $model->bind($itemData);
        }
        // Apply the Form name
        $formName = 'form.form';
        if (!empty($this->layout)) {
            $formName = 'form.' . $this->layout;
        }
        $this->getModel()->setFormName($formName);
        // Do we have a _valid_ form?
        $form = $this->getModel()->getForm($model);
        if ($form !== false) {
            $this->hasForm = true;
        }
        // Display the view
        $this->display(in_array('add', $this->cacheableTasks), $this->cacheParams);
    }