I just got into Symfony2 as an ASP.NET programmer. I have this very simple form that I want to put in. Since it only contains a label and an input, I figured I didn't want to make a separate form class for it. But as soon as I tried to preform that, I ran into some trouble:
<form action="{{ path('search', [{'src':'bla'}]) }}" method="get">
<label for="src"></label>
<input type="text" name="src" id="src" class="form-control search-input" placeholder="Type a group or song name: ie. Metallica, Fly me to the moon etc.">
</form>
How do I set the path to mydomain.com/search/{src}
, I'm trying to at least build a path for now, so I'm using 'bla' as some placeholder valye. Right now from the code above, I receive the following error upon loading the page that contains the form:
An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("src") to generate a URL for route "search".") in :home:index.html.twig
Some methods I also tried:
path('search', 'bla') <-- and --> path('search', 'bla', [])
brings error:
An exception has been thrown during the rendering of a template ("Warning: array_replace(): Argument #3 is not an array") in :home:index.html.twig
path('search', ['src':'bla'])
and some more (probably) nonsense that didn't get me close to the result.
Is this even doable, or do I have to do it the 'normal' way with {{ form_start() }}
and form classes?