Creates a form to edit an entity.

@param mixed $entity The entity

@return \Symfony\Component\Form\Form The form
497401
protected function createEditForm($entity)
    {
        $form = $this->createForm(
            $this->getEditFormType(), $entity, [
                'action' => $this->generateUrl($this->getRouteName() . "Edit", $this->getRouteParams(['id' => $entity->getId()])),
                'method' => 'POST',
            ]
        );

        return $form;
    }
584684
public function actionCreate($entity)
    {
        /* @var $commentModel CommentModel */
        $commentModel = Yii::createObject($this->getModule()->commentModelClass);
        $event = Yii::createObject(['class' => CommentEvent::class, 'commentModel' => $commentModel]);
        $commentModel->setAttributes($this->getCommentAttributesFromEntity($entity));
        $this->trigger(self::EVENT_BEFORE_CREATE, $event);
        if ($commentModel->load(Yii::$app->request->post()) && $commentModel->saveComment()) {
            $this->trigger(self::EVENT_AFTER_CREATE, $event);

            return ['status' => 'success'];
        }

        return [
            'status' => 'error',
            'errors' => ActiveForm::validate($commentModel),
        ];
    }
39840
public function setEntity($entity)
    {
        $this->debugLog(sprintf('ENTITY: %s', $entity));

        $expectedEntity = $this->makeSQLSafe($this->getParams()['DBPREFIX'] . $entity);

        $this->debugLog(sprintf('SET ENTITY: %s', $expectedEntity));

        // Concatinate the entity with the sqldbprefix value only if not already done.
        if ($expectedEntity !== $this->entity) {
            $this->entity = $expectedEntity;
        }

        return $this;
    }
724764
private function createCreateForm(RegistrationRole $entity)
    {
        $form = $this->createForm('sam_create_role', $entity, array(
            'action' => $this->generateUrl('sam_role_create'),
            'method' => 'POST'
        ));

        return $form;
    }
751431
private function createEditForm(MessageType $entity)
    {
        $form = $this->createForm(MessageTypeType::class, $entity, array(
            'action' => $this->generateUrl('messagetype_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));
        $this->_addFunctionsToForm($form);

        $form->add('submit', SubmitType::class, array('label' => 'Update'));
        return $form;
    }
767426
public function insert($entity)
    {
        if (!$entity instanceof $this->entityClass) {
            throw new \InvalidArgumentException(
                "The entity to be inserted must be an instance of {$this->entityClass}."
            );
        }

        return $this->adapter->insert($this->entityTable, $entity->toArray());
    }
19642
private function createEditForm(Country $entity)
    {
        $form = $this->createForm(new CountryType($this->get('doctrine.orm.entity_manager')->getRepository('OrkestroLocaleBundle:Locale')), $entity, array(
            'action' => $this->generateUrl('orkestro_backend_country_update', array('iso_code' => $entity->getIsoCode())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
1347770
private function createCreateForm(ProductOrderItem $entity)
    {
        $form = $this->createForm(new ProductOrderItemType(), $entity, array(
            'action' => $this->generateUrl('admin_orderitem_create'),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }
650401
protected function manageEdit($entity, Request $request, $formTypeFQCN)
    {
        $form = $this->createForm($formTypeFQCN, $entity, array(
            'action' => $this->getEditUrl($entity),
            'method' => 'POST',
        ));

        $form
            ->add('save', SubmitType::class, array('attr' => array('class' => 'btn btn-primary')))
            ->add('delete', SubmitType::class, array('attr' => array('class' => 'btn btn-danger')));

        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            if ($form->get('save')->isClicked()) {
                if ($form->isValid()) {
                    return $this->crudManage($entity, AdminCrudEvent::UPDATE);
                }
            } elseif ($form->get('delete')->isClicked()) {
                return $this->crudManage($entity, AdminCrudEvent::DELETE);
            }
        }

        return $this->render(
            $this->getEditTemplate(),
            array(
                'entity' => $entity,
                'form' => $form->createView(),
            ));
    }
1029817
private function createEditForm(Contract $entity)
    {
        $form = $this->createForm(new ContractType(), $entity, array(
            'action' => $this->generateUrl('ecommerce_contract_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

//        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
1362001
private function createMenuItemCreateForm(MenuItem $entity)
    {
        $form = $this->createForm(new MenuItemType(), $entity, array(
            'action' => $this->generateUrl('admin_menu_item_create', array('id' => $entity->getMenu()->getId())),
            'method' => 'POST',
        ));

        $form->add('submit', 'submit', array('label' => 'Create'));

        return $form;
    }
588454
public function insert($entity)
    {
        $entity->set($this->_property, $this->getRoot());

        //only add the entity into the entityset if it has
        //already been loaded
        //otherwise don't
        if ($this->getObject()->isLoaded()) {
            $this->getObject()->insert($entity);
        }

        return $entity;
    }
739471
public function addEntity($entity)
    {
        $this->collection[] = $entity;
        $this->setCount(count($this->collection));

        return $this;
    }
1331008
private function createEditForm(Episode $entity)
    {
        $form = $this->createForm(
            new EpisodeType(),
            $entity,
            [
                'action' => $this->generateUrl(
                    'oktolab_episode_update',
                    ['id' => $entity->getId()]
                ),
                'method' => 'POST'
            ]
        );

        $form->add(
            'submit',
            'submit',
            ['label' => 'oktolab_media.edit_episode_button']
        );

        return $form;
    }
1131260
private function createEditForm(Block $entity) {
        $form = $this->createForm(new BlockType(), $entity, array(
            'action' => $this->generateUrl('block_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        $form->add('submit', 'submit', array('label' => 'Update'));

        return $form;
    }
443718
private function createEditForm(Role $entity)
    {
        $form = $this->createForm('sam_role', $entity, array(
            'action' => $this->generateUrl('sam_role_update', array('id' => $entity->getId())),
            'method' => 'PUT',
        ));

        return $form;
    }
1154074
public function persist($entity)
    {
        $entityArray = $this->toArray($entity);
        $instance    = $this->getInstanceFromIdentityMap($entity);

        if ($instance) {
            $this->fillExistingInstanceFromEntityArray($instance, $entityArray);
        }
        if (!$instance) {
            $instance = $this->createInstanceFromEntityArray($entityArray);
        }
        $this->persistanceQueue[] = $instance;

        return $this;
    }