1

I have a method that creates a form like this:

class search {

  public function index() {} 

  public function createSearch() {

  $form = $this->createFormBuilder(null)
   ->add(...)
   ->add('search', SubmitType::class, ['attr' => 'action' => 'http://foo.bar/tar'])->getForm();

   return $this->render(...); 
 }

}

As you can see I want the createSearch to create a form that will submit into url 'http://foo.bar/tar' but when submit the form it does not go to that page

1 Answer 1

3

You are adding an action attribute to your submit button, it is supposed to go with your form tag.

Form builder has a setAction method.

$this->createFormBuilder(null)
  ->setAction('http://foo.bar/tar')

https://symfony.com/doc/current/form/action_method.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.