editAction override from CRUDController.

@param int|null $id Object id

@see Sonata\AdminBundle\Controller\CRUDController::edit()

@return Response|RedirectResponse
494841
public function editAction($id = null)
    {
        try {
            return parent::editAction($id);
        } catch (\Exception $e) {
            return $this->editActionException($e);
        }
    }
791705
public function edit($id) {

        // Is this user allowed to do this?
        if (!$this->repository->isUserAllowed('edit')) {
            Session::flash('status_code', 400 );
            $message = "You are not allowed to edit ".$this->model->table;
            Session::flash('message', $message);
            return view('formhandling::warnings/' . config('lasallecmsadmin.admin_template_name') . '/user_not_allowed', [
                'package_title'                => $this->model->package_title,
                'table_type_plural'            => $this->model->table,
                'resource_route_name'          => $this->model->resource_route_name,
                'table_type_singular'          => strtolower($this->model->model_class),
                'HTMLHelper'                   => HTMLHelper::class,
            ]);
        }

        // Is this record locked?
        if ($this->repository->isLocked($id)) {

            $modelClass = HTMLHelper::properPlural($this->model->model_class);

            $message    = "This ".$modelClass." is not available for editing, as someone else is currently editing this ".$modelClass.".";
            Session::flash('message', $message);
            Session::flash('status_code', 400 );
            return Redirect::route('admin.'.$this->model->resource_route_name.'.index');
        }

        // Lock the record
        $this->repository->populateLockFields($id);

        return view('lasallecmsemail::admin/emailhandling/edit',
            [
                'user'                         => Auth::user(),
                'repository'                   => $this->repository,
                'record'                       => $this->repository->getFind($id),
                'package_title'                => $this->model->package_title,
                'table_name'                   => $this->model->table,
                'model_class'                  => $this->model->model_class,
                'resource_route_name'          => $this->model->resource_route_name,
                'priorityIdField'              => $this->model->priorityIdField,
                'DatesHelper'                  => DatesHelper::class,
                'HTMLHelper'                   => HTMLHelper::class,
                'Config'                       => Config::class,
                'admin_size_input_text_box'    => Config::get('lasallecmsadmin.admin_size_input_text_box'),
                'admin_template_name'          => config('lasallecmsadmin.admin_template_name'),
                'Form'                         => Form::class,
            ]);
    }
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);
    }
908636
public function edit($id = null) {
		$block = $this->Blocks->get($id, [
			'contain' => []
		]);
		if ($this->request->is(['patch', 'post', 'put'])) {
			$block = $this->Blocks->patchEntity($block, $this->request->data);
			if ($this->Blocks->save($block)) {
				$this->Flash->success('The block has been saved.');
				return $this->redirect(['action' => 'index']);
			} else {
				$this->Flash->error('The block could not be saved. Please, try again.');
			}
		}
		$this->set(compact('block'));
	}
778287
public function editAction($id)
        {

            /** @var RemoteApp $oRemoteApp */
            $oRemoteApp = RemoteAppQuery::create()->findOneById($id);

            if (count($oRemoteApp) === 0) {
                throw $this->createNotFoundException('Unable to find RemoteApp entity.');
            }

            $editForm   = $this->createEditForm($oRemoteApp);
            $deleteForm = $this->createDeleteForm($id);

            return $this->render('SlashworksAppBundle:RemoteApp:edit.html.twig', array(
                'entity'      => $oRemoteApp,
                'edit_form'   => $editForm->createView(),
                'delete_form' => $deleteForm->createView(),
            ));
        }
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()),
            ]
        );
    }
1248218
public function edit($id = null) {
		$cell = $this->Cells->get($id, [
			'contain' => []
		]);
		if ($this->request->is(['patch', 'post', 'put'])) {
			$cell = $this->Cells->patchEntity($cell, $this->request->data);
			if ($this->Cells->save($cell)) {
				$this->Flash->success('The cell has been saved.');
				return $this->redirect(['action' => 'index']);
			} else {
				$this->Flash->error('The cell could not be saved. Please, try again.');
			}
		}
		$this->set(compact('cell'));
	}
62333
public function edit($id = null) {
		$queuedJob = $this->QueuedJobs->get($id, [
			'contain' => []
		]);
		if ($queuedJob->completed) {
			$this->Flash->error(__('The queued job is already completed.'));
			return $this->redirect(['action' => 'index']);
		}

		if ($this->request->is(['patch', 'post', 'put'])) {
			$queuedJob = $this->QueuedJobs->patchEntity($queuedJob, $this->request->getData());
			if ($this->QueuedJobs->save($queuedJob)) {
				$this->Flash->success(__('The queued job has been saved.'));
				return $this->redirect(['action' => 'index']);
			}

			$this->Flash->error(__('The queued job could not be saved. Please try again.'));
		}

		$this->set(compact('queuedJob'));
	}
1180926
public function edit($id = null)
    {
        $profile = $this->Profiles->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $profile = $this->Profiles->patchEntity($profile, $this->request->data);
            if ($this->Profiles->save($profile)) {
                $this->Flash->success(__('The profile has been saved.'));

                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error(__('The profile could not be saved. Please, try again.'));
        }
        $users = $this->Profiles->Users->find('list', ['limit' => 200]);
        $this->set(compact('profile', 'users'));
        $this->set('_serialize', ['profile']);
    }
674862
public function edit(string $id)
    {
        $table = $this->loadModel();

        $entity = $this->fetchEntity($id);

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

            // enable accessibility to associated entity's primary key
            // to avoid associated entity getting flagged as new
            $options = $table instanceof Table ? $table->enablePrimaryKeyAccess() : [];

            $response = $this->persistEntity($entity, $post_data, $options);
            if ($response) {
                $this->saveAssociations($entity, $post_data);

                return $response;
            }
        }

        $this->set('entity', $entity);
        $this->render('CsvMigrations.Common/edit');
        $this->set('_serialize', ['entity']);
    }
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,
			]);
	}
839355
public function edit(string $id = null)
    {
        $translation = $this->Translations->get($id, [
            'contain' => ['Languages']
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $data = is_array($this->request->getData()) ? $this->request->getData() : [];
            $translation = $this->Translations->patchEntity($translation, $data);
            if ($this->Translations->save($translation)) {
                $this->Flash->success((string)__('The translation has been saved.'));

                return $this->redirect(['action' => 'index']);
            }
            $this->Flash->error((string)__('The translation could not be saved. Please, try again.'));
        }
        $languages = $this->Translations->Languages->find('list', ['limit' => 200]);
        $this->set(compact('translation', 'languages'));
        $this->set('_serialize', ['translation']);
    }
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'));

    }
169020
public function edit($id = null)
    {
        set_meta('title', 'Write a Page');

        $content = Content::page()->where('id', $id)->firstOrFail();

        $this->authorize('update', $content);

        return view('orchestra/story::admin.editor', [
            'content' => $content,
            'url'     => handles("orchestra::storycms/pages/{$content->getAttribute('id')}"),
            'method'  => 'PUT',
        ]);
    }
1138313
public function getEdit($id = null)
    {
        $group = Sentinel::getRoleRepository()->find($id);

        // Get the group's information
        if($group == null)
        {
            // Prepare the error message
            $error = Lang::get('base.groups.not_found');

            // Redirect to the post management page
            return Redirect::route('groups')->with('error', $error);
        }

        $groups = null;

        $groups2 = Sentinel::getRoleRepository()->all(['id', 'name']);

        foreach ($groups2 as $g)
            $groups[$g->id] = $g->name;

        // Show the page
        return View('admin.groups.edit', compact('group', 'groups'));
    }
756283
public function actionEdit($id = null)
    {
        if ($id === null) {
            $model = new CountryLanguage;
        } else {
            $model = $this->findModel($id);
        }
        $isLoaded = $model->load(Yii::$app->request->post());
        $hasAccess = ($model->isNewRecord && Yii::$app->user->can('multilingual-create-country-language'))
            || (!$model->isNewRecord && Yii::$app->user->can('multilingual-edit-country-language'));
        if ($isLoaded && !$hasAccess) {
            throw new ForbiddenHttpException;
        }
        if ($isLoaded && $model->save()) {
            return $this->redirect(['edit', 'id' => $model->id]);
        } else {
            return $this->render(
                'edit',
                [
                    'hasAccess' => $hasAccess,
                    'model' => $model,
                ]
            );
        }
    }
455622
public function edit($id = null)
    {
        $cmsTermRelation = $this->CmsTermRelation->get($id, [
            'contain' => []
        ]);
        if ($this->request->is(['patch', 'post', 'put'])) {
            $cmsTermRelation = $this->CmsTermRelation->patchEntity($cmsTermRelation, $this->request->data);
            if ($this->CmsTermRelation->save($cmsTermRelation)) {
                $this->Flash->success('The cms term relation has been saved.');
                return $this->redirect(['action' => 'index']);
            } else {
                $this->Flash->error('The cms term relation could not be saved. Please, try again.');
            }
        }
        $cmsTermTaxonomy = $this->CmsTermRelation->CmsTermTaxonomy->find('list', ['limit' => 200]);
        $cmsContent = $this->CmsTermRelation->CmsContent->find('list', ['limit' => 200]);
        $this->set(compact('cmsTermRelation', 'cmsTermTaxonomy', 'cmsContent'));
        $this->set('_serialize', ['cmsTermRelation']);
    }