Edit method

@param string|null $id Menu id.
@return void Redirects on successful edit, renders view otherwise.
339665
public function edit(string $id = null): void
    {
        $menu = $this->Menus->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $data = (array)$this->request->getData();
            $menu = $this->Menus->patchEntity($menu, $data);
            if ($this->Menus->save($menu)) {
                $this->Flash->success((string)__('The menu has been saved.'));
                $this->redirect(['action' => 'index']);

                return;
            } else {
                $this->Flash->error((string)__('The menu could not be saved. Please, try again.'));
            }
        }
        $this->set('navMenu', $menu);
        $this->set('_serialize', ['navMenu']);
    }
1067056
public function edit($id)
    {
      if ( \Auth::user()->roles[0]->can('menu-update' ) ) {
        $menu = $this->menus->findOrFail($id);
        $items = $this->menus->pluck('name', 'id')->toarray();
        $roles = Role::lists('name', 'id')->toarray();
        $selected = $menu->roles->pluck('id')->toarray();
        return view('admin.menus.edit', compact('menu', 'selected', 'roles', 'items'));
      }
      return \Redirect::route('admin.menus.index')->withErrors(trans('acl::dashboard.unauthorized_access'));

    }
891640
public function edit($id)
    {
        $this->request->allowMethod(['get', 'put']);

        $menu = $this->Menus->get($id);

        if ($this->request->is('put')) {
            $menu = $this->Menus->patchEntity($menu, $this->request->data);
            if ($this->Menus->save($menu)) {
                $this->Flash->success(__d('wasabi_core', 'The menu <strong>{0}</strong> has been saved.', $this->request->data['name']));
                $this->redirect(['action' => 'index']);
                return;
            } else {
                $this->Flash->error($this->formErrorMessage);
            }
        }
        $this->set([
            'menu' => $menu,
            'menuItems' => $this->MenuItems->find('threaded', ['order' => ['lft' => 'ASC']])->where(['MenuItems.menu_id' => $id])->hydrate(false)
        ]);
        $this->render('add');
    }
82875
public function edit($id)
	{
		return $this->response()
			->view($this->getView('edit'), [
				'entity' => $this->getModel()->getRepository()->getById($id)
			]);
	}
630472
public function renderAdd(int $id = null): void
	{
		$this['editForm']->setDefaults([
			'locale' => $this->localeService->defaultLocaleId,
			'parent' => $id
		]);
		$this->setView('edit');
		$this->template->viewLinks = false;
	}
849445
public function edit($id)
    {
        $tag = $this->model->findOrFail($id);

        return view('LaravelAdminBlog::tags.edit')
            ->with('tag', $tag)
            ->with('activeMenu', 'sidebar.Blog.Tags');
    }
251843
public function editAction($id = null)
    {
        $request = $this->getRequest();
        $this->manager = $this->getDoctrine()->getManager();
        // the key used to lookup the template
        $templateKey = 'edit';

        $id = $request->get($this->admin->getIdParameter());
        $object = $this->admin->getObject($id);

        if (!$object) {
            throw $this->createNotFoundException(sprintf('unable to find the object with id : %s', $id));
        }

        $this->admin->checkAccess('edit', $object);

        $preResponse = $this->preEdit($request, $object);
        if ($preResponse !== null) {
            return $preResponse;
        }

        $this->admin->setSubject($object);

        /** @var $form Form */
        $form = $this->admin->getForm();
        $form->setData($object);
        $form->handleRequest($request);

        $this->handleFiles($object);

        if ($form->isSubmitted()) {
            //TODO: remove this check for 3.0
            if (method_exists($this->admin, 'preValidate')) {
                $this->admin->preValidate($object);
            }
            $isFormValid = $form->isValid();

            // persist if the form was valid and if in preview mode the preview was approved
            if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
                try {
                    $object = $this->admin->update($object);

                    if ($this->isXmlHttpRequest()) {
                        return $this->renderJson(array(
                                    'result'     => 'ok',
                                    'objectId'   => $this->admin->getNormalizedIdentifier($object),
                                    'objectName' => $this->escapeHtml($this->admin->toString($object)),
                                        ), 200, array());
                    }

                    $this->addFlash(
                        'sonata_flash_success',
                        $this->admin->trans(
                            'flash_edit_success',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );

                    // redirect to edit mode
                    return $this->redirectTo($object);
                } catch (ModelManagerException $e) {
                    $this->handleModelManagerException($e);

                    $isFormValid = false;
                } catch (LockException $e) {
                    $this->addFlash('sonata_flash_error', $this->admin->trans('flash_lock_error', array(
                                '%name%'       => $this->escapeHtml($this->admin->toString($object)),
                                '%link_start%' => '<a href="' . $this->admin->generateObjectUrl('edit', $object) . '">',
                                '%link_end%'   => '</a>',
                                    ), 'SonataAdminBundle'));
                }
            }

            // show an error message if the form failed validation
            if (!$isFormValid) {
                if (!$this->isXmlHttpRequest()) {
                    $this->addFlash(
                        'sonata_flash_error',
                        $this->admin->trans(
                            'flash_edit_error',
                            array('%name%' => $this->escapeHtml($this->admin->toString($object))),
                            'SonataAdminBundle'
                        )
                    );
                }
            } elseif ($this->isPreviewRequested()) {
                // enable the preview template if the form was valid and preview was requested
                $templateKey = 'preview';
                $this->admin->getShow();
            }
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->defineFormTheme($view, $this->admin->getFormTheme());

        return $this->render($this->admin->getTemplate($templateKey), array(
                    'action' => 'edit',
                    'form'   => $view,
                    'object' => $object,
                        ), null);
    }
502156
public function setId($id = null)
    {
        if ($id !== null) {
            $id = preg_replace("/[^a-z0-9_\\\d]/i", '_', $id);

            $this->id = (string) $id;
        }
    }
95967
public function edit($id) {
		$dep        = Dep::find($id);
		$department = Dep::where('parent', null)->pluck('name_'.app('l'), 'id');
		return view('admin.department.edit', ['title' => trans('admin.edit'),
				'department'                                => $department,
				'edit'                                      => $dep,
			]);
	}
943221
public function edit(string $id)
    {
        $savedWidgetData = [];
        $dashboard = $this->Dashboards->get($id, [
            'contain' => ['Widgets']
        ]);

        $dashboardWidgets = $dashboard->get('widgets');
        $dashboard->unsetProperty('widgets');

        /**
         * @var \Search\Model\Table\WidgetsTable $widgetsTable
         */
        $widgetsTable = TableRegistry::get('Search.Widgets');
        $widgets = $widgetsTable->getWidgets();

        $sequence = 0;

        foreach ($dashboardWidgets as $dw) {
            foreach ($widgets as $widget) {
                if ($dw->widget_id !== $widget['data']['id']) {
                    continue;
                }

                $widgetOptions = $widgetsTable->getWidgetOptions($dw, ['sequence' => $sequence]);

                $item = array_merge(
                    [
                        'id' => $widget['data']['id']
                    ],
                    [
                        'data' => $widget['data']
                    ],
                    $widgetOptions
                );
                unset($item['data']['content'], $item['data']['created'], $item['data']['modified']);
                if (!empty($item['data']['query'])) {
                    unset($item['data']['query']);
                }
                array_push($savedWidgetData, $item);

                $sequence++;
            }
        }

        if ($this->request->is(['patch', 'post', 'put'])) {
            $data = (array)$this->request->getData();

            $dashboard->unsetProperty('widgets');

            $dashboard = $this->Dashboards->patchEntity($dashboard, [
                'name' => $data['name'],
                'role_id' => $data['role_id']
            ]);

            if ($this->Dashboards->save($dashboard)) {
                $this->Flash->success((string)__('The dashboard has been saved.'));
                /** @var \Search\Model\Table\WidgetsTable */
                $widgetTable = TableRegistry::get('Search.Widgets');
                $widgetTable->trashAll([
                    'dashboard_id' => $dashboard->id
                ]);

                $data['widgets'] = !empty($data['options']) ? json_decode($data['options'], true) : [];
                if (!empty($data['widgets'])) {
                    $widgetsTable->saveDashboardWidgets($id, $data['widgets']);
                }

                return $this->redirect(['action' => 'view', $id]);
            } else {
                $this->Flash->error((string)__('The dashboard could not be saved. Please, try again.'));
            }
        }

        $roles = $this->Dashboards->Roles->find('list', ['limit' => 200]);

        $this->set(compact('dashboard', 'roles', 'widgets', 'savedWidgetData'));
        $this->set('columns', Configure::readOrFail('Search.dashboard.columns'));
        $this->set('_serialize', ['dashboard']);
    }
907206
public function handleDelete(int $id): void
	{
		if ($this->isAjax() && $this->editConst) {
			$content = $this->orm->content->getById($id);
			$this->orm->content->removeAndFlush($content);
			$this['list']->reload();
		} else {
			$this->terminate();
		}
	}
410051
public function view($id = null)
    {
        $role = $this->Roles->get($id, [
            'contain' => []
        ]);
        $this->set('role', $role);

        $this->render(Configure::read('CM.AdminRoleViews.view'));
    }
1332703
public function edit($id = null) {
        $this->loadModel('CmsContent');
        $cmsContent = $this->CmsContent->get($id, [
            'contain' => []
        ]);

        /**
         * 
         */
        if ($cmsContent->content_type != 'news') :
            $this->Flash->error('The cms content is not NEWS object');
            return $this->redirect(['action' => 'index']);
        endif;

        /**
         * 
         */
        if ($this->request->is(['patch', 'post', 'put'])) {

            /**
             * Before save the Content
             */
            $cmsContent->parent = 0;
            $cmsContent->name = parent::_permittedContentName($id, trim($this->request->data['name']));
            $cmsContent->content_title = $this->request->data['content_title'];
            $cmsContent->content_description = $this->request->data['content_description'];
            $cmsContent->content_excerpt = '';
            $cmsContent->content_deadline = $this->request->data['content_deadline'];
            $cmsContent->password = $this->request->data['content_password'];
            $cmsContent->content_status = $this->request->data['content_status'];
            $cmsContent->publish_start = $this->request->data['publish_start'];
            $cmsContent->publish_end = $this->request->data['publish_end'];
            $cmsContent->author = '';
            $cmsContent->modified = date('Y-m-d H:i:s');
            
            /**
             * Default button_publish_action
             */
            if (isset($this->request->data['button_publish_action']))
                $cmsContent->content_status = 'publish';


            if ($this->CmsContent->save($cmsContent)) {

                /**
                 * Save all related elements
                 */
                if (isset($this->request->data['related']['page']) && count($this->request->data['related']['page']))
                    parent::saveRelatedPage($id, $this->request->data['related']['page']);
                if (isset($this->request->data['related']['attached']) && count($this->request->data['related']['attached']))
                    parent::saveRelatedAttached($id, $this->request->data['related']['attached']);
                if (isset($this->request->data['related']['image']) && count($this->request->data['related']['image']))
                    parent::saveRelatedImage($id, $this->request->data['related']['image']);
                if (isset($this->request->data['related']['meta']) && count($this->request->data['related']['meta']))
                    parent::saveRelatedMeta($id, $this->request->data['related']['meta']);

                /**
                 * Delete related contents
                 */
                if (isset($this->request->data['delete_ck']['content_id']))
                    foreach ($this->request->data['delete_ck']['content_id'] as $key => $val) :
                        parent::deleteRelatedContent($key);
                    endforeach;

                /**
                 * Delete related meta
                 */
                if (isset($this->request->data['delete_ck']['meta_id']))
                    foreach ($this->request->data['delete_ck']['meta_id'] as $key => $val) :
                        parent::deleteRelatedMeta($key);
                    endforeach;

                /**
                 * Set FLASH and redirect
                 */
                $this->Flash->success('The cms content has been saved.');
                if (isset($this->request->data['button_save_action']))
                    return $this->redirect(['action' => 'edit', $id]);
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error('The cms content could not be saved. Please, try again.');
            }
        }

        /**
         * Set parent_news_list
         */
        $cmsContent['parent_news_list'] = $this->_getParentNewsList($id);

        /**
         * Set content_status_list
         */
        $cmsContent['content_status_list'] = ['draft' => 'Draft', 'publish' => 'Publish'];

        /**
         * Set list of taxonomy
         */
        $where = ['taxonomy' => 'news'];
        $cmsContent['list_of_taxonomy'] = parent::getListOfTaxonomy($where);

        /**
         * Set list of taxonomy checked
         */
        $relationTable = TableRegistry::get('CmsTermRelation');
        $query = $relationTable->find()
                ->select(['cms_term_taxonomy_id'])
                ->where(['cms_content_id' => $id]);
        $cmsContent['list_of_taxonomy_checked'] = $query->all();

        /**
         * Set list of user
         */
        $cmsContent['list_of_user'] = parent::getListOfUser();

        /**
         * Set list of user checked
         */
        $cmsPermissionTable = TableRegistry::get('CmsPermission');
        $query = $cmsPermissionTable->find()
                ->select(['sys_user_id'])
                ->where(['cms_content_id' => $id]);
        $cmsContent['list_of_user_checked'] = $query->all();

        /**
         * Set list of role
         */
        $cmsContent['list_of_role'] = parent::getListOfRole();

        /**
         * Set list of role checked
         */
        $cmsPermissionTable = TableRegistry::get('CmsPermission');
        $query = $cmsPermissionTable->find()
                ->select(['sys_role_id'])
                ->where(['cms_content_id' => $id]);
        $cmsContent['list_of_role_checked'] = $query->all();

        /**
         * Create related array
         */
        $cmsContent['related'] = array();

        /**
         * Set related news
         */
        $where = ['parent' => $id, 'content_type' => 'news'];
        $cmsContent['related']['news'] = parent::getListOfContent($where);

        /**
         * Set related image
         */
        $where = ['parent' => $id, 'content_type' => 'image'];
        $cmsContent['related']['image'] = parent::getListOfContent($where);

        /**
         * Set related attached
         */
        $where = ['parent' => $id, 'content_type' => 'attached'];
        $cmsContent['related']['attached'] = parent::getListOfContent($where);

        /**
         * Set related meta
         */
        $where = ['cms_content_id' => $id];
        $cmsContent['related']['meta'] = parent::getListOfMeta($where);

        /**
         * 
         */
        $this->set('data', $cmsContent);
        $this->set('_serialize', ['data']);
    }
887177
public function change($id = null)
    {
        if ($id === null || !$this->Languages->exists(['id' => $id])) {
            $this->Flash->error($this->invalidRequestMessage);
            $this->redirect($this->referer());
            return;
        }
        $this->request->session()->write('contentLanguageId', (int)$id);
        $this->redirect($this->referer());
    }
409644
public function edit($id = null)
    {
        $user = $this->Users->get($id);

        //Only the admin founder can edit others admin users
        if ($user->group_id === 1 && !$this->Auth->isFounder()) {
            $this->Flash->alert(I18N_ONLY_ADMIN_FOUNDER);

            return $this->redirect(['action' => 'index']);
        }

        $user = $this->Users->patchEntity($user, $this->request->getData(), ['validate' => 'EmptyPassword']);

        if ($this->request->is(['patch', 'post', 'put'])) {
            if ($this->Users->save($user)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('user'));
    }
1321754
public function edit($id = null)
    {
        $tag = $this->PostsTags->Tags->get($id);

        if ($this->request->is(['patch', 'post', 'put'])) {
            $tag = $this->PostsTags->Tags->patchEntity($tag, $this->request->getData());

            if ($this->PostsTags->Tags->save($tag)) {
                $this->Flash->success(I18N_OPERATION_OK);

                return $this->redirect(['action' => 'index']);
            }

            $this->Flash->error(I18N_OPERATION_NOT_OK);
        }

        $this->set(compact('tag'));
    }
32420
public function editAction($id = null)
    {
        /** @var Request $request */
        $request = $this->getRequest();
        // the key used to lookup the template
        $templateKey = 'edit';

        if ($id === null) {
            $id = $request->get($this->admin->getIdParameter());
        }

        $object = $this->admin->getObject($id);

        if (!$object) {
            throw new NotFoundHttpException(sprintf('unable to find the object with id : %s', $id));
        }

        if (false === $this->admin->isGranted('EDIT', $object)) {
            throw new AccessDeniedException();
        }

        $this->admin->setSubject($object);

        /** @var $form \Symfony\Component\Form\Form */
        $form = $this->admin->getForm();
        $form->setData($object);

        if ($request->getMethod() == 'POST') {
            if (!$this->isXmlHttpRequest()) {
                throw new NotFoundHttpException('Should only submit over ajax');
            }

            $request->attributes->add(['objectId' => $id]);
            $request->attributes->add(['page_locale' => $object->getLocale()]);

            $form->handleRequest($request);

            if ($form->isValid()) {
                $object->setStatus(PageInterface::STATUS_DRAFT);
                $this->admin->update($object);

                return $this->getAjaxEditResponse($form, $object);
            } else {
                $form->addError(new FormError($this->translate('flash_edit_error', [], 'NetworkingInitCmsBundle')));
            }
        }

        $view = $form->createView();

        // set the theme for the current Admin Form
        $this->setFormTheme($view, $this->admin->getFormTheme());

        $rootMenus = $this->admin->getModelManager()->findBy(
            'NetworkingInitCmsBundle:MenuItem',
            ['isRoot' => 1, 'locale' => $object->getLocale()]
        );

        return $this->renderWithExtraParams(
            $this->admin->getTemplate($templateKey),
            [
                'action' => 'edit',
                'form' => $view,
                'object' => $object,
                'rootMenus' => $rootMenus,
                'language' => \Locale::getDisplayLanguage($object->getLocale()),
            ]
        );
    }