public function editAction()
    {
        $id = (int) $this->params()->fromRoute('id', null);

        $request = $this->getRequest();
        $service = $this->getService();
        $entity  = $service->getById($id);

        $form     = $this->getEditForm();
        $form->bind($entity);

        if ($request->getQuery()->get('redirect')) {
            $redirect = $request->getQuery()->get('redirect');
        } else {
            $redirect = false;
        }

        $redirectUrl = $this->url()->fromRoute($this->getEditActionRoute(), array('id' => $id)) . ($redirect ? '?redirect=' . $redirect : '');
        $prg = $this->prg($redirectUrl, true);

        if ($prg instanceof Response) {
            return $prg;
        } elseif ($prg === false) {
            return array(
                'options'  => $this->getOptions(),
                'id'       => $id,
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        $post   = $prg;
        $entity = $service->update($id, $post);

        $redirect = isset($prg['redirect']) ? $prg['redirect'] : null;

        if (!$entity) {
            return array(
                'options'  => $this->getOptions(),
                'id'       => $id,
                'form'     => $form,
                'redirect' => $redirect,
            );
        }

        return $this->redirect()->toUrl($this->url()->fromRoute($this->getRouteIdentifierPrefix()) . ($redirect ? '?redirect='.$redirect : ''));
    }