Displays a form to create a new Product entity.

@Route("/new", name="admin_product_new")
@Method("GET")
@Template()
543246
public function newAction()
    {
        $entity = new Product();

        $entity = $this->addProductItemFieldData($entity);


        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
810544
public function newAction()
    {
        $form = $this->getServiceLocator()->get('playgrounddesign_theme_form');

        $request = $this->getRequest();
        $themeEntity = new themeEntity;

        if ($request->isPost()) {
            $data = array_merge(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            );

            $theme = $this->getAdminThemeService()->create($data, 'playgrounddesign_theme_form');
            if ($theme) {
                $this->flashMessenger()->addMessage('The theme "'.$theme->getTitle().'" was created');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            } else {
                $this->flashMessenger()->addMessage('The theme was not created');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            }
        }

        $viewModel = new ViewModel();
        $viewModel->setTemplate('playground-design/theme-admin/theme');

        return $viewModel->setVariables(array('form'           => $form,
                                              'automaticTheme' => 0));
    }
586576
public function newAction()
    {
        $user = new User();
        $form   = $this->createCreateForm($user);

        return $this->render('ChillMainBundle:User:new.html.twig', array(
            'entity' => $user,
            'form'   => $form->createView(),
        ));
    }
546376
public function actionCreate()
	{
		$model=new Post;
		if(isset($_POST['Post']))
		{
			$model->attributes=$_POST['Post'];
			if($model->save())
				$this->redirect(array('view','id'=>$model->id));
		}

		$this->render('create',array(
			'model'=>$model,
		));
	}
88686
public function create()
    {
        $roles = Role::select('id', 'name', 'label')->get();
        $roles = $roles->pluck('label', 'name');

        return view('admin.users.create', compact('roles'));
    }
234064
public function createAction(Request $request)
    {
        $productitemfield = new ProductItemField();
        $form = $this->createForm($this->get("amulen.shop.form.product.item.field"), $productitemfield);
        if ($form->handleRequest($request)->isValid()) {
            $productitemSrv = $this->get('amulen.shop.product.item.field');
            $productitemSrv->uploadImage($productitemfield);
            $em = $this->getDoctrine()->getManager();
            $em->persist($productitemfield);
            $em->flush();

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

        return array(
            'productitemfield' => $productitemfield,
            'form' => $form->createView(),
        );
    }
47693
public function createAction(Request $request)
    {
        $entity = new Product();
        $entity = $this->addProductItemFieldData($entity);
        $form = $this->createCreateForm($entity);
        $form->handleRequest($request);

        if ($form->isValid()) {
            $em = $this->getDoctrine()->getManager();
            /* persist product */
            $em->persist($entity);

            if (is_null($entity->getMediaGallery())) {
                /* create media gallery */
                $mediaGallery = new Gallery();
                $mediaGallery->setName($entity->getName());
                $mediaGallery->setEnabled(true);
                $em->persist($mediaGallery);

                /* set media gallery */
                $entity->setMediaGallery($mediaGallery);
            }

            $em->flush();

            $this->get('session')->getFlashBag()->add(
                'success', $this->get('translator')->trans('save_success')
            );

            return $this->redirect($this->generateUrl('admin_product_show', array('id' => $entity->getId())));
        } else {
            $this->get('session')->getFlashBag()->add(
                'warning', $this->get('translator')->trans('save_fail')
            );
        }

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
396995
def admin_add
      return if !user_is_allowed('products', 'add')
      
      resp = Caboose::StdClass.new(
        :error => nil,
        :redirect => nil
      )
      
      title = params[:title]
      
      if title.length == 0
        resp.error = "The title cannot be empty."
      else
        p = Product.new(:title => title)
        p.save
        resp.redirect = "/admin/products/#{p.id}/general"
      end
      render :json => resp    
    end
585633
public function newAction()
        {
            $oUser = new User();
            $form   = $this->createCreateForm($oUser);

            return $this->render('SlashworksBackendBundle:User:new.html.twig', array(
                'entity' => $oUser,
                'form'   => $form->createView(),
            ));
        }
1148767
public function create($type, Request $request)
    {
        if ($type && $product = $this->productManager->findByNamespace($type)) {
            $categories = $this->category->all()->nest()->listsFlattened('name');
            $shops = $this->shop->all();
            $optionTypes = $this->optionManager->all();

            return view('product::admin.products.create', compact('product', 'categories', 'shops', 'optionTypes'));
        }

        // If type is not exists, default type will be set
        $first = $this->productManager->first();

        return redirect()->route($request->route()->getName(), ['type' => $first->getEntityNamespace()]);
    }
1036366
public function createAction()
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth(AdminResources::MODULE, Team::getModuleCode(),
                AccessManager::CREATE)
        ) {
            return $response;
        }

        // Create the Creation Form
        $creationForm = $this->getCreationForm($this->getRequest());

        $con = Propel::getConnection();
        $con->beginTransaction();

        try {
            // Check the form against constraints violations
            $form = $this->validateForm($creationForm, "POST");
            // Get the form field values
            $data = $form->getData();

            $createdObject = $this->getService()->createFromArray($data, $this->getCurrentEditionLocale());


            // Substitute _ID_ in the URL with the ID of the created object
            $successUrl = str_replace('_ID_', $this->getObjectId($createdObject), $creationForm->getSuccessUrl());

            $con->commit();

            // Redirect to the success URL
            return $this->generateRedirect($successUrl);

        } catch (FormValidationException $ex) {
            $con->rollBack();
            // Form cannot be validated
            $error_msg = $this->createStandardFormValidationErrorMessage($ex);
        } catch (\Exception $ex) {
            $con->rollBack();
            // Any other error
            $error_msg = $ex->getMessage();
        }
        if (false !== $error_msg) {
            $this->setupFormErrorContext(
                $this->getTranslator()->trans("%obj creation", ['%obj' => static::CONTROLLER_ENTITY_NAME]),
                $error_msg,
                $creationForm,
                $ex
            );

            // At this point, the form has error, and should be redisplayed.
            return $this->getListRenderTemplate();
        }

    }
1257943
public function newAction()
    {
        $ticketManager = $this->get('hackzilla_ticket.ticket_manager');
        $entity        = $ticketManager->createTicket();

        $form = $this->createForm(TicketType::class, $entity);

        return $this->render(
            $this->container->getParameter('hackzilla_ticket.templates')['new'],
            [
                'entity' => $entity,
                'form'   => $form->createView(),
            ]
        );
    }
375777
public function createAction()
    {
        $request = $this->getRequest();
        // the key used to lookup the template
        $templateKey = 'edit';

        $this->admin->checkAccess('create');

        $class = new \ReflectionClass($this->admin->hasActiveSubClass() ? $this->admin->getActiveSubClass() : $this->admin->getClass());

        if ($class->isAbstract()) {
            return $this->renderWithExtraParams(
                '@SonataAdmin/CRUD/select_subclass.html.twig',
                [
                    'base_template' => $this->getBaseTemplate(),
                    'admin' => $this->admin,
                    'action' => 'create',
                ],
                null
            );
        }

        $newObject = $this->admin->getNewInstance();

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

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

        $form = $this->admin->getForm();

        if (!\is_array($fields = $form->all()) || 0 === \count($fields)) {
            throw new \RuntimeException(
                'No editable field defined. Did you forget to implement the "configureFormFields" method?'
            );
        }

        $form->setData($newObject);
        $form->handleRequest($request);

        if ($form->isSubmitted()) {
            $isFormValid = $form->isValid();

            // persist if the form was valid and if in preview mode the preview was approved
            if ($isFormValid && (!$this->isInPreviewMode() || $this->isPreviewApproved())) {
                $submittedObject = $form->getData();
                $this->admin->setSubject($submittedObject);
                $this->admin->checkAccess('create', $submittedObject);

                try {
                    $newObject = $this->admin->create($submittedObject);

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

                    $this->addFlash(
                        'sonata_flash_success',
                        $this->trans(
                            'flash_create_success',
                            ['%name%' => $this->escapeHtml($this->admin->toString($newObject))],
                            'SonataAdminBundle'
                        )
                    );

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

                    $isFormValid = false;
                }
            }

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

        $formView = $form->createView();
        // set the theme for the current Admin Form
        $this->setFormTheme($formView, $this->admin->getFormTheme());

        // NEXT_MAJOR: Remove this line and use commented line below it instead
        $template = $this->admin->getTemplate($templateKey);
        // $template = $this->templateRegistry->getTemplate($templateKey);

        return $this->renderWithExtraParams($template, [
            'action' => 'create',
            'form' => $formView,
            'object' => $newObject,
            'objectId' => null,
        ], null);
    }
172930
public function newAction()
    {
        $center = new Center();
        $form   = $this->createCreateForm($center);

        return $this->render('ChillMainBundle:Center:new.html.twig', array(
            'entity' => $center,
            'form'   => $form->createView(),
        ));
    }
136876
public function newAction()
        {

            $oCustomer = new Customer();
            $form      = $this->createCreateForm($oCustomer);

            return $this->render('SlashworksAppBundle:Customer:new.html.twig', array(
                'entity' => $oCustomer,
                'form'   => $form->createView(),
            ));
        }
798809
public function newAction() {
        $entity = new Block();
        $form = $this->createCreateForm($entity);

        return array(
            'entity' => $entity,
            'form' => $form->createView(),
        );
    }
726637
public function newAction()
    {
        $model = $this->loadModel();
        if (!$model->isObjectNew()) {
            $this->_forward('noroute');
            return;
        }

        if ($this->getRequest()->isPost()) {
            $postData = $this->getRequest()->getPost();
            try {
                $model->isObjectNew(true);
                foreach ($this->preprocessPostData($postData) as $key => $value) {
                    $model->setDataUsingMethod($key, $value);
                }
                $model->save();
                $this->_redirectUrl($this->getHelper()->getGridUrl());
                $this->_getSession()->addSuccess('Saved Successfully');
                return;
            } catch (Exception $e) {
                $message = $e->getMessage();
                if ($e instanceof Zend_Db_Statement_Exception && $e->getChainedException() instanceof PDOException) {
                    /** @var PDOException $e */
                    $e = $e->getChainedException();
                    if (isset($e->errorInfo[0]) && $e->errorInfo[0] == 23000 && isset($e->errorInfo[1]) && $e->errorInfo[1] == 1062) {
                        $message = $this->getHelper()->__(
                            "Record already exists for %s '%s'",
                            $model->getIdFieldName(),
                            $model->getId()
                        );
                    }
                }
                Mage::logException($e);
                $this->_getSession()->addError($message);
            }
        }

        $this->loadLayout();
        $this->renderLayout();
    }