Show the form for creating a new resource.

@param Request $request The request object.

@return mixed
349455
public function create(Request $request)
    {
        if ($request->wantsJson()) {
            return $this->validNotFoundJsonResponse();
        }

        $model = new $this->repository->model;

        $view = $this->getViewLocation(__FUNCTION__);
        $this->checkViewExists($view);

        return response()->view($view, compact('model'));
    }
1254740
public function editAction(Request $request)
    {
        $form     = $this->validateRequestParameters($request);
        $resource = $this->mapper->getResource($request->get('id'));

        $this->mapper->populateResourceWithForm($resource, $form);
        $this->mapper->update($resource);

        // returns an empty 200 (OK)
        return new Response();
    }
27317
public function createAction(Request $request)
    {
        $errors = [];
        $question = null;

        $data = $this->decodeRequestData($request);
        if (empty($data)) {
            // Invalid or empty JSON data received
            $errors[] = [
                'path' => '',
                'message' => 'Invalid JSON data',
            ];
        } else {
            // Try to update question with data
            try {
                $question = $this->manager->create($data);
            } catch (InvalidDataException $e) {
                $errors = $e->getErrors();
            }
        }

        if (empty($errors)) {
            // Item updated
            return new JsonResponse(
                $this->manager->serialize($question, [Transfer::INCLUDE_SOLUTIONS, Transfer::INCLUDE_ADMIN_META])
            );
        } else {
            // Invalid data received
            return new JsonResponse($errors, 422);
        }
    }
699591
public function createAction(Request $request)
    {
        $shopSetting = new ShopSetting();
        $form = $this->createForm(new ShopSettingType(), $shopSetting);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($shopSetting);
            $em->flush();

            return $this->redirect($this->generateUrl('admin_amulen_shop_setting_show', array('id' => $shopSetting->getId())));
        }

        return array(
            'shopSetting' => $shopSetting,
            'form' => $form->createView(),
        );
    }
823912
public function createAction(Request $request)
        {
            $oUser = new User();
            $form = $this->createCreateForm($oUser);
            $form->handleRequest($request);

            if ($form->isValid()) {

                $factory  = $this->get('security.encoder_factory');
                $encoder  = $factory->getEncoder($oUser);
                $password = $encoder->encodePassword($oUser->getPassword(), $oUser->getSalt());
                $oUser->setPassword($password);
                $oUser->save();

                return $this->redirect($this->generateUrl('backend_system_user'));
            }

            return $this->render('SlashworksBackendBundle:User:new.html.twig', array(
                'entity' => $oUser,
                'form'   => $form->createView(),
            ));
        }
445631
public function newAction(Request $request)
    {
        /** @var ContentTypeInterface $contentType */
        $contentType = $this->get('open_orchestra_backoffice.manager.content_type')->initializeNewContentType();

        $action = $this->generateUrl('open_orchestra_backoffice_content_type_new', array());
        $form = $this->createContentTypeForm($request, array(
            'action' => $action,
            'new_button' => true,
            'need_link_to_site_defintion' => true,
        ), $contentType);

        $form->handleRequest($request);
        if ('PATCH' !== $request->getMethod()) {
            if ($form->isValid()) {
                $contentType->setVersion(1);
                $language = $this->get('open_orchestra_backoffice.context_backoffice_manager')->getBackOfficeLanguage();
                $documentManager = $this->get('object_manager');
                $documentManager->persist($contentType);
                $documentManager->flush();
                $message = $this->get('translator')->trans('open_orchestra_backoffice.form.content_type.creation');
                $this->dispatchEvent(ContentTypeEvents::CONTENT_TYPE_CREATE, new ContentTypeEvent($contentType));
                $response = new Response(
                    $message,
                    Response::HTTP_CREATED,
                    array('Content-type' => 'text/plain; charset=utf-8', 'contentTypeId' => $contentType->getContentTypeId(), 'name' => $contentType->getName($language))
                );

                return $response;
            }
        }

        return $this->renderAdminForm($form);
    }
150029
public function create(Request $request)
    {
        app('soda.interface')->setHeading('New Role');
        app('soda.interface')->breadcrumbs()->addLink(route('soda.roles.index'), 'Roles');

        try {
            $role = $this->roles->newInstance($request);
            $permissionIds = $this->roles->getPermissions();
        } catch (Exception $e) {
            return $this->handleException($e, trans('soda::errors.create', ['object' => 'role']));
        }

        return soda_cms_view('data.roles.view', compact('role', 'permissionIds'));
    }
726544
public function newAction(Request $request)
    {
        $series = $this->get('oktolab_media')->createSeries();
        $form = $this->createForm(SeriesType::class, $series);
        $form->add('submit', SubmitType::class, ['label' => 'oktolab_media.new_series_button', 'attr' => ['class' => 'btn btn-primary']]);

        if ($request->getMethod() == "POST") { //sends form
            $form->handleRequest($request);
            $em = $this->getDoctrine()->getManager();
            if ($form->isValid()) { //form is valid, save or preview
                if ($form->get('submit')->isClicked()) { //save me
                    $em->persist($series);
                    $em->flush();
                    $this->get('session')->getFlashBag()->add('success', 'oktolab_media.success_create_series');
                    return $this->redirect($this->generateUrl('oktolab_series_show', ['series' => $series->getUniqId()]));
                } else { //???
                    $this->get('session')->getFlashBag()->add('success', 'oktolab_media.unknown_action_series');
                    return $this->redirect($this->generateUrl('oktolab_series'));
                }
            }
            $this->get('session')->getFlashBag()->add('error', 'oktolab_media.error_create_series');
        }

        return ['form' => $form->createView()];
    }
1185394
public function createAction(Request $request)
    {
        $class = $this->admin->getEntity();
        $data = new $class();

        return $this->editAction($request, $data);
    }
88415
public function createAction(Request $request)
    {
        $inventoryitem = new InventoryItem();
        $form = $this->createForm(new InventoryItemType(), $inventoryitem);
        if ($form->handleRequest($request)->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($inventoryitem);
            $em->flush();

            return $this->redirect($this->generateUrl('stock_inventory_show', array('id' => $inventoryitem->getInventory()->getId())));
        }

        return array(
            'inventoryitem' => $inventoryitem,
            'form' => $form->createView(),
        );
    }
845166
public function newAction(Request $request)
    {
        $em = $this->getDoctrine()->getManager();
        $template = new Template();
        $form = $this->container->get('form.factory')->create(TemplateType::class, $template);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $em->persist($template);
            $em->flush();

            return new JsonResponse([
                'success' => true,
                'url'     => $this->generateUrl('victoire_template_show', ['id' => $template->getId()]),
            ]);
        }

        return new JsonResponse(
            [
                'success' => true,
                'html'    => $this->container->get('templating')->render(
                    'VictoireTemplateBundle:Template:new.html.twig',
                    ['form' => $form->createView()]
                ),
            ]
        );
    }
931182
public function createAction(Request $request)
    {
        $contentTypeManager = $this->get('opifer.content.content_type_manager');

        $contentType = $contentTypeManager->create();

        $form = $this->createForm(ContentTypeType::class, $contentType);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            foreach ($form->getData()->getSchema()->getAttributes() as $attribute) {
                $attribute->setSchema($contentType->getSchema());

                foreach ($attribute->getOptions() as $option) {
                    $option->setAttribute($attribute);
                }
            }

            $contentTypeManager->save($contentType);

            $this->addFlash('success', 'Content type has been created successfully');

            return $this->redirectToRoute('opifer_content_contenttype_edit', ['id' => $contentType->getId()]);
        }

        return $this->render($this->getParameter('opifer_content.content_type_create_view'), [
            'content_type' => $contentType,
            'form' => $form->createView(),
        ]);
    }
642911
public function newAction(Request $request)
    {
        $statusClass = $this->getParameter('open_orchestra_model.document.status.class');
        /** @var StatusInterface $status */
        $status = new $statusClass();
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, StatusInterface::ENTITY_TYPE);

        $form = $this->createForm('oo_status', $status, array(
            'action' => $this->generateUrl('open_orchestra_workflow_admin_status_new'),
            'method' => 'POST',
            'new_button' => true
        ));

        $form->handleRequest($request);

        if ($form->isValid()) {
            $documentManager = $this->get('object_manager');
            $documentManager->persist($status);
            $documentManager->flush();
            $message = $this->get('translator')->trans('open_orchestra_workflow_admin.form.status.creation');
            $this->get('session')->getFlashBag()->add('success', $message);

            $this->dispatchEvent(StatusEvents::STATUS_CREATE, new StatusEvent($status));
            $response = new Response(
                '',
                Response::HTTP_CREATED,
                array('Content-type' => 'text/html; charset=utf-8', 'statusId' => $status->getId(), 'name' => $status->getLabel($this->get('open_orchestra_backoffice.context_backoffice_manager')->getBackOfficeLanguage()))
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
650695
public function createAction(Request $request)
    {
        $this->denyAccessUnlessGranted('ROLE_ADMIN');

        $domain = new Domain();

        $form = $this->createForm(DomainType::class, $domain);
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            $em->persist($domain);
            $em->flush();

            $this->addFlash('success', 'Domaim has been created successfully');

            return $this->redirectToRoute('opifer_cms_domain_edit', ['id' => $domain->getId()]);
        }

        return $this->render('OpiferCmsBundle:Backend/Domain:create.html.twig', [
            'domain' => $domain,
            'form' => $form->createView()
        ]);
    }
628064
public function newAction(Request $request)
    {
        $keywordClass = $this->container->getParameter('open_orchestra_model.document.keyword.class');
        /** @var KeywordInterface $keyword */
        $keyword = new $keywordClass();
        $this->denyAccessUnlessGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE);

        $form = $this->createForm('oo_keyword', $keyword, array(
            'action' => $this->generateUrl('open_orchestra_backoffice_keyword_new'),
            'method' => 'POST',
            'new_button' => true
        ));

        $form->handleRequest($request);
        $message = $this->get('translator')->trans('open_orchestra_backoffice.form.keyword.creation');

        if ($this->handleForm($form, $message, $keyword)) {
            $this->dispatchEvent(KeywordEvents::KEYWORD_CREATE, new KeywordEvent($keyword));
            $response = new Response(
                '',
                Response::HTTP_CREATED,
                array('Content-type' => 'text/html; charset=utf-8', 'keywordId' => $keyword->getId(),  'name' => $keyword->getLabel())
            );

            return $response;
        }

        return $this->renderAdminForm($form);
    }
1289014
public function newAction(Request $request)
    {
        $entity = new Translation();
        $form = $this->createForm('CoreBundle\Form\TranslationType', $entity);
        
        $form->handleRequest($request);

        if ($form->isSubmitted() && $form->isValid()) {

            //Create entry in DB
            $this->updateTranslation($entity);
            
            $this->get('session')->getFlashBag()->add('success', 'translation.created');
            
            return $this->redirectToRoute('core_translation_index');
        }

        return $this->render('CoreBundle:Translation:new.html.twig', array(
            'translation' => $entity,
            'form' => $form->createView(),
        ));
    }
70987
public function create(Request $request)
    {
        /** @var \SymfonyId\AdminBundle\Configuration\ConfiguratorFactory $configuratorFactory */
        $configuratorFactory = $this->getConfiguratorFactory($this->getClassName());
        /** @var CrudConfigurator $crudConfigurator */
        $crudConfigurator = $configuratorFactory->getConfigurator(CrudConfigurator::class);

        $this->isGrantedOr404Error($crudConfigurator, Constants::ACTION_CREATE);

        $modelClass = $crudConfigurator->getCrud()->getModelClass();
        $form = $crudConfigurator->getForm();
        $form->setData(new $modelClass());

        return $this->save($request, $form, $crudConfigurator);
    }