本文整理汇总了PHP中Symfony\Component\Form\FormInterface::isSubmitted方法的典型用法代码示例。如果您正苦于以下问题:PHP FormInterface::isSubmitted方法的具体用法?PHP FormInterface::isSubmitted怎么用?PHP FormInterface::isSubmitted使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormInterface
的用法示例。
在下文中一共展示了FormInterface::isSubmitted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleGameDetailForm
/**
* @return Response|null
*/
private function handleGameDetailForm(Request $request, FormInterface $form, GameDetailForm $formObject)
{
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid() && !$form->get('dealGame')->isClicked()) {
throw new BadRequestHttpException('invalid or missing submit action');
}
if ($form->isSubmitted() && $form->isValid() && $form->get('dealGame')->isClicked()) {
$this->gameService->deal($formObject->getGameId());
return $this->redirectToRoute(self::ROUTE_GAME_DETAIL, ['gameId' => $formObject->getGameId()]);
}
return;
}
示例2: registerUser
/**
* @param FormInterface $form
* @return int|false ID of inserted data OR success
*/
public function registerUser(FormInterface $form)
{
if ($this->encoder == null) {
throw new \Exception("Encoder can not be NULL! Do you added the Encoder by using add_encoder() ??");
}
if ($form->isValid()) {
$data = $form->getData();
$entity = new GBUserEntry();
$entity->setNick($data['nick']);
$entity->setPass($this->encodePassword($entity, $data['password']));
try {
$this->emanager->persist($entity);
$this->emanager->flush();
return $entity->getUid();
} catch (\Exception $ex) {
$this->errormessage = $ex->getMessage();
if (strstr($this->errormessage, "Duplicate")) {
$this->errormessage = "Dieser Nick wird bereits verwendet!";
}
return false;
}
} elseif ($form->isSubmitted()) {
$this->errormessage = (string) $form->getErrors(true);
}
return false;
}
示例3: handle
public function handle(FormInterface $form, Request $request)
{
$form->handleRequest($request);
if (!$form->isValid()) {
return false;
}
$data = $form->getData();
if ($form->isSubmitted()) {
$user = $this->userManager->findUserByEmail($data['email']);
if (is_null($user)) {
$form->addError(new FormError($this->translator->trans('security.resetting.request.errors.email_not_found')));
return false;
}
if ($user->isPasswordRequestNonExpired($this->tokenTll)) {
$form->addError(new FormError($this->translator->trans('security.resetting.request.errors.password_already_requested')));
return false;
}
if ($user->getConfirmationToken() === null) {
$user->setConfirmationToken($this->tokenGenerator->generateToken());
}
$user->setPasswordRequestedAt(new \DateTime());
$this->userManager->resettingRequest($user);
}
return true;
}
示例4: buildView
/**
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
$view->vars['valid'] = $valid = !$form->isSubmitted() || $form->isValid();
$view->vars['icon'] = $valid ? $options['icon'] : $options['error_icon'];
$view->vars['tab_active'] = false;
$view->parent->vars['vic_tabbed'] = true;
}
示例5: buildView
/**
* Adds on constraints found in data class' metadata (yaml/xml/annotations)
*
* {@inheritdoc}
*/
public function buildView(FormView $view, FormInterface $form, array $options)
{
if (!$form->isSubmitted()) {
if ($this->metaDataConstraintService instanceof MetaDataConstraintService) {
$this->metaDataConstraintService->mergeConstraints($form);
}
}
}
示例6: handleCreateGameForm
/**
* @param Request $request
* @param FormInterface $form
*
* @return Response|null
*/
private function handleCreateGameForm(Request $request, FormInterface $form, CreateGameForm $formObject)
{
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$gameId = $this->gameService->createGame($formObject->getName());
return $this->redirectToRoute(self::ROUTE_GAME_DETAIL, ['gameId' => $gameId]);
}
return;
}
示例7: validateForm
/**
* @param FormInterface $form
*/
private function validateForm(FormInterface $form)
{
if (!$form->isSubmitted()) {
throw new \InvalidArgumentException("FormCriteriaDecorator expects form to be submitted");
}
if (!$form->isValid()) {
throw new \InvalidArgumentException("FormCriteriaDecorator expects form to be valid.");
}
}
示例8: isFormSubmitted
/**
* @param FormInterface $form
* @param Request $request
* @return bool
*/
protected function isFormSubmitted(FormInterface $form, Request $request)
{
if ($request->isMethod('POST')) {
$form->handleRequest($request);
return $form->isSubmitted();
} else {
return false;
}
}
示例9: getCriteriaFromForm
/**
* @return array|mixed
*/
protected function getCriteriaFromForm()
{
$criteria = [];
if (null === $this->form) {
return $criteria;
}
$this->form->handleRequest($this->request);
if ($this->form->isSubmitted() && $this->form->isValid() || !$this->form->isSubmitted()) {
$criteria = ArrayHelper::arrayForce($this->form->getData());
}
return $criteria;
}
示例10: handle
/**
* @param FormInterface $form
* @param Request $request
*
* @return mixed|FormInterface
*/
public function handle(FormInterface $form, Request $request)
{
$method = $request->getMethod();
$form->submit($request, 'PATCH' !== $method);
if ($form->isSubmitted() && $form->isValid()) {
$entity = $form->getData();
$this->registry->getManager()->persist($entity);
$this->registry->getManager()->flush();
return $entity;
}
return $form;
}
示例11: getRegistryData
/**
* Gets the registry data given a submitted form.
* Default configuration is returned if no form provided.
*
* @param FormInterface $form
*
* @return array
*
* @throws RuntimeException
*/
public function getRegistryData(FormInterface $form = null)
{
$data = [];
if (null !== $form) {
if (!$form->isSubmitted()) {
throw new RuntimeException('Form must have been submitted');
}
$newData = $form->getData();
$data = $this->filterNullValues($newData);
}
return array_replace_recursive($this->getDefaultData(), $data);
}
示例12: processPageForm
/**
* @param Request $request
* @param FormInterface $form
*
* @param Page $page
*
* @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
*/
public function processPageForm(Request $request, $form, $page = null)
{
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$page = $form->getData();
$em = $this->get('doctrine.orm.entity_manager');
$em->persist($page);
$em->flush();
return $this->redirect($this->generateUrl('taforum_admin_page', array('pagePermalink' => $page->getPagePermalink())));
}
return $this->render('TerAelisForumBundle:Page:admin_page_edit.html.twig', array('page' => !empty($page) ? $page : null, 'form' => $form->createView()));
}
示例13: renderAdminForm
/**
* Render admin form and tag response with status 400 if form is badly completed
*
* @param FormInterface $form
* @param array $params additional view parameters
* @param Response|null $response
* @param string $template
*
* @return Response
*/
protected function renderAdminForm(FormInterface $form, array $params = array(), $response = null, $template = self::TEMPLATE)
{
if (is_null($response)) {
$code = Response::HTTP_OK;
if ($form->isSubmitted() && !$form->isValid()) {
$code = Response::HTTP_UNPROCESSABLE_ENTITY;
}
$response = new Response('', $code, array('Content-type' => 'text/html; charset=utf-8'));
}
$params = array_merge($params, array('form' => $form->createView()));
return $this->render($template, $params, $response);
}
示例14: create
public function create(FormInterface $form, Request $request)
{
$form->handleRequest($request);
if (!$form->isValid()) {
return false;
}
$entity = $form->getData();
if ($form->isSubmitted()) {
if (!is_null($this->manager->checkUniqueEmail($entity->getUser()->getEmail()))) {
$form->addError(new FormError('Email ja cadastrado!'));
return false;
}
}
$this->manager->create($entity);
return true;
}
示例15: handlePlayerForm
/**
* @param Request $request
* @param FormInterface $form
* @param GameDetailDto $game
* @param PlayerDto $player
*
* @return Response|null
*/
private function handlePlayerForm(Request $request, FormInterface $form, GameDetail $game, Player $player)
{
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
if ($form->get('play')->isClicked()) {
$turnNumber = $form->getData()->getTurnNumber();
$move = $form->getData()->getMove();
if ($move && $move->isPlay()) {
$play = new Play($turnNumber, new Stone($move->getStoneTopValue(), $move->getStoneBottomValue()), $move->getSide() === 'left' ? Play::SIDE_LEFT : Play::SIDE_RIGHT);
$this->gameService->play($game->getId(), $player->getNumber(), $play);
return $this->redirectToRoute(self::ROUTE_PLAYER_DETAIL, ['gameId' => $form->getData()->getGameId(), 'playerNumber' => $form->getData()->getPlayerNumber()]);
}
}
}
return;
}