I added the following routes in ME\MYBUNDLE\RESOURCES\CONFIG\ROUTING.YML:
my_homepage: pattern: / defaults: { _controller: MeMyBundle:Default:index }
Bundle Controller
namespace Me\MyBundle\Controller;use Symfony\Bundle\FrameworkBundle\Controller\Controller;class DefaultController extends Controller{ public function indexAction() { $form = $this->createFormBuilder() ->getForm() ; return $this->render('MeMyBundle::index.html.twig', array( 'form' => $form->createView(), 'param1' => 'some_string_1', 'param2' => 'another string', )); }}
I want to create a custom form field that can be reused in the same form table dropdowns, with the following code
public function indexAction() { $paramsArr_1 = array( 'param1' => 'some_string_1', 'param2' => 'another string', ); $paramsArr_2 = array( 'param1' => 'some_string_2', 'param2' => 'another fine string', ); $form = $this->createFormBuilder() ->add(myCustomField, $paramsArr_1) ->add(myCustomField_2, $paramsArr_2) ->getForm() ; return $this->render('MeMyBundle::index.html.twig', array( 'form' => $form->createView() )); }
Reference the official documentation, but still not, who knows?
Reply content:
I added the following routes in ME\MYBUNDLE\RESOURCES\CONFIG\ROUTING.YML:
my_homepage: pattern: / defaults: { _controller: MeMyBundle:Default:index }
Bundle Controller
namespace Me\MyBundle\Controller;use Symfony\Bundle\FrameworkBundle\Controller\Controller;class DefaultController extends Controller{ public function indexAction() { $form = $this->createFormBuilder() ->getForm() ; return $this->render('MeMyBundle::index.html.twig', array( 'form' => $form->createView(), 'param1' => 'some_string_1', 'param2' => 'another string', )); }}
I want to create a custom form field that can be reused in the same form table dropdowns, with the following code
public function indexAction() { $paramsArr_1 = array( 'param1' => 'some_string_1', 'param2' => 'another string', ); $paramsArr_2 = array( 'param1' => 'some_string_2', 'param2' => 'another fine string', ); $form = $this->createFormBuilder() ->add(myCustomField, $paramsArr_1) ->add(myCustomField_2, $paramsArr_2) ->getForm() ; return $this->render('MeMyBundle::index.html.twig', array( 'form' => $form->createView() )); }
Reference the official documentation, but still not, who knows?