本文整理匯總了PHP中Symfony\Component\Form\Form::handleRequest方法的典型用法代碼示例。如果您正苦於以下問題:PHP Form::handleRequest方法的具體用法?PHP Form::handleRequest怎麽用?PHP Form::handleRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\Form\Form
的用法示例。
在下文中一共展示了Form::handleRequest方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: processPostedForm
/**
* @param Request $request
* @param Form $form
* @param Eleve $eleve
* @return bool
*/
private function processPostedForm(Request $request, Form $form, Eleve $eleve, Period $periode)
{
$em = $this->getDoctrine()->getManager();
$form->handleRequest($request);
if ($form->isValid()) {
$temporary_taps_to_persist = $eleve->getTaps();
// retire toutes les inscriptions au TAP pour la période qui ne sont pas
// et qui n'ont pas été enregistré par le parent
// dans la nouvelle sélection
$repo = $em->getRepository('WCSCantineBundle:Eleve');
$eleve_taps_periode = $repo->findAllTapsForPeriode($eleve, $periode, true);
foreach ($eleve_taps_periode as $item) {
if (!$temporary_taps_to_persist->contains($item)) {
$em->remove($item);
}
}
// retire toutes les inscriptions à la garderie pour la période qui ne sont pas
// et qui n'ont pas été enregistré par le parent
// dans la nouvelle sélection
$temporary_garderies_to_persist = $eleve->getGarderies();
$eleve_garderies_periode = $repo->findAllGarderiesForPeriode($eleve, $periode, true);
foreach ($eleve_garderies_periode as $item) {
if (!$temporary_garderies_to_persist->contains($item)) {
$em->remove($item);
}
}
$eleve->setTapgarderieSigned(true);
$em->flush();
return true;
}
return false;
}
示例2: bindRequest
/**
* @param Request $request
*/
public function bindRequest(Request $request)
{
$this->form->handleRequest($request);
foreach ($this->tabs as $tab) {
$tab->bindRequest($request);
}
}
示例3: process
/**
* @return bool
*/
public function process()
{
$this->form->handleRequest($this->request);
if ($this->form->isValid()) {
return $this->onSuccess();
}
return false;
}
示例4: processPostedForm
/**
* @param Request $request
* @param Form $form
* @param Eleve $eleve
* @return bool
*/
private function processPostedForm(Request $request, Form $form, Eleve $eleve)
{
$em = $this->getDoctrine()->getManager();
$form->handleRequest($request);
if ($form->isValid()) {
// la nouvelle sélection de dates (avec celles déjà présentes en
// base de données, et les nouvelles à ajouter
// (cette liste a été mise à jour avec LunchToStringTransformer)
$lunchesNew = $eleve->getLunches();
// récupère les réservations actuellement en base de données
$lunchesOld = $em->getRepository("WCSCantineBundle:Lunch")->findByEleve($eleve);
// supprime les dates qui ne sont plus sélectionnées
foreach ($lunchesOld as $lunchOld) {
if (!$lunchesNew->contains($lunchOld)) {
$em->remove($lunchOld);
}
}
$eleve->setCanteenSigned(true);
// met à jour la fiche élève (le régime alimentaire,...)
$em->persist($eleve);
$em->flush();
return true;
}
return false;
}
示例5: bindForm
public function bindForm(Request $request)
{
$this->form->handleRequest($request);
if ($this->form->isValid()) {
$this->writeTranslationsToFile($request->request->all());
return true;
}
return false;
}
示例6: handle
/**
* @param Form $form
* @throws MethodNotAllowedException
* @throws ValidatorException
*/
protected function handle(Form $form)
{
if (false === $this->getRequest()->isMethod('POST')) {
throw new MethodNotAllowedException(array('POST'), 'Form can be posted only by "POST" method.');
}
$form->handleRequest($this->getRequest());
if (false === $form->isValid()) {
throw new ValidatorException('Form object validation failed, form is invalid.');
}
}
示例7: processForm
/**
* @param \Symfony\Component\Form\Form $form
* @param \Symfony\Component\HttpFoundation\Request $request
*/
private function processForm(Form $form, Entry $entry, Request $request)
{
$form->handleRequest($request);
if ($form->isValid()) {
$this->getEm()->persist($entry);
$this->getEm()->flush();
return true;
}
return false;
}
示例8: handleConfigForm
/**
* @param Request $request
* @param Form $form
*
* @return array|boolean
*/
public function handleConfigForm(Request $request, Form $form)
{
if ($request->isMethod('post')) {
$form->handleRequest($request);
if ($form->isValid()) {
return $form->getData();
}
}
return false;
}
示例9: process
public function process(Form $form, Request $request)
{
if (!$request->isMethod('POST')) {
return false;
}
$form->handleRequest($request);
if ($form->isValid()) {
return $this->processValidForm($form, $request);
}
return false;
}
示例10: handleFormRequest
/**
* @param Form $form
* @param Request $request
* @return bool|\Symfony\Component\HttpFoundation\RedirectResponse
*/
private function handleFormRequest(Form $form, Request $request)
{
$form->handleRequest($request);
if (!$form->isValid()) {
return false;
}
$userEntity = $this->initUser($form->getData());
$em = $this->getDoctrine()->getManager();
$em->persist($userEntity);
$em->flush();
return true;
}
示例11: validate
/**
* validate
*
* @param Form $form Form
* @param Request $request Request
*
* @return boolean
*/
public function validate(Form $form, Request $request)
{
if ($this->hasMethod($request->getMethod())) {
if ($request->getMethod() != 'POST') {
$form->submit($request);
} else {
$form->handleRequest($request);
}
return $form->isValid();
}
return false;
}
示例12: process
/**
* @param Form $form
* @param Request $request
*
* @return bool
*/
public function process(Form $form, Request $request)
{
if (!$request->isMethod('POST')) {
return false;
}
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
$data = $form->getData();
$this->em->persist($data);
$this->em->flush();
return true;
}
return false;
}
示例13: isValid
private function isValid(Request $request, Form $form)
{
$session = $request->getSession();
if ('POST' === $request->getMethod()) {
$form->handleRequest($request);
if ($form->isValid()) {
$sessionData = $session->get(self::SESSION_KEY) ?: array();
$formData = array_replace_recursive($sessionData, $form->getData());
$session->set(self::SESSION_KEY, $formData);
return true;
}
}
return false;
}
示例14: buildFilterQuery
public function buildFilterQuery()
{
$em = $this->getDoctrine()->getManager();
$qb = $em->createQueryBuilder()->select('a')->from($this->entity, 'a');
if (null !== $this->filterForm) {
$this->filterForm->handleRequest($this->request);
if ($this->filterForm->isSubmitted() && $this->filterForm->isValid()) {
$data = $this->filterForm->getData();
foreach ($data as $name => $value) {
if (substr($name, 0, 7) === 'filter_') {
$this->filtersType[substr($name, 7)] = $value;
} else {
if (null !== $value) {
$this->filters[] = [$name, $value];
}
}
}
}
}
foreach ($this->filters as $key => $filter) {
$filterType = '=';
if (isset($this->filtersType[$filter[0]])) {
$filterType = $this->filtersType[$filter[0]];
$value = $filter[1];
if ($this->filtersType[$filter[0]] === 'contains') {
$value = '%' . $filter[1] . '%';
$filterType = 'like';
}
}
if (0 === $key) {
$qb->where('a.' . $filter[0] . ' ' . $filterType . ' :a_' . $filter[0])->setParameter('a_' . $filter[0], $value);
} else {
$qb->andWhere('a.' . $filter[0] . ' ' . $filterType . ' :a_' . $filter[0])->setParameter('a_' . $filter[0], $value);
}
}
return $qb;
}
示例15: onlyAction
/**
* @param Request $request
* @param string $key
* @return RedirectResponse|Response
* @throws NotFoundHttpException
*/
public function onlyAction(Request $request, $key)
{
$ajaxTemplates = $this->container->getParameter('l91.sulu.form.ajax_templates');
if (!$ajaxTemplates[$key]) {
throw new NotFoundHttpException();
}
$this->form = $this->getFormHandler()->get($key, $request->query->all());
if ($request->isMethod('post')) {
$this->form->handleRequest($request);
if ($this->getFormHandler()->handle($this->form)) {
return new RedirectResponse('?send=true');
}
}
return $this->render($ajaxTemplates[$key], array('form' => $this->form->createView()));
}