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

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

Single record edit. The ID set in the request is passed to the model, then the form layout is used to edit the result.
public edit ( ) : void
Результат void
    public function edit()
    {
        // Load the model
        /** @var DataModel $model */
        $model = $this->getModel()->savestate(false);
        if (!$model->getId()) {
            $this->getIDsFromRequest($model, true);
        }
        $userId = $this->container->platform->getUser()->id;
        try {
            if ($model->isLocked($userId)) {
                $model->checkIn($userId);
            }
            $model->lock();
        } catch (\Exception $e) {
            // Redirect on error
            if ($customURL = $this->input->getBase64('returnurl', '')) {
                $customURL = base64_decode($customURL);
            }
            $url = !empty($customURL) ? $customURL : 'index.php?option=' . $this->container->componentName . '&view=' . $this->container->inflector->pluralize($this->view) . $this->getItemidURLSuffix();
            $this->setRedirect($url, $e->getMessage(), 'error');
            return;
        }
        // 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';
        }
        // 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.' . $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('edit', $this->cacheableTasks), $this->cacheParams);
    }