Support the ongoing development of Laravel.io →
posted 5 years ago
Forms

I have a form which works as a filter and consist of select, text field and few buttons (1-10). Select and the text field works, they reload the page, repopulate them self (keep the value chosen by user) and sent the data to the controller.

{{Form::select('nameOfSelect', ['item1' => 'value1', 'item2' => 'value2',], null, ['class'=> 'css-style', 'onchange' => 'this.form.submit()'])}}

{{Form::text('search', '', ['class'=> 'css-style', 'placeholder' => 'Search'])}}

With var_dump($request->all()); I can display the values of the elements.

How would a button look like which gives back a value? What I need:
<button class="CSS" name="5" value="5" type="submit">5</button>

The docs* provide this for a submit button:

{{Form::submit('Click Me!')}} //don't give back a value
{{Form::submit('Click Me!', 'XXXvalue)}} //error

//I tried this and get an error
{{Form::submit('Click Me!', '', 'xxx',['class'=> 'btn btn-outline-success mr-2','onchange' => 'this.form.submit()'])}}
//error message Illegal string offset 'name', 
//Note: '', must be avaible in Form::text, therefore I added it to Form::submit, don't work with or without it.

Thank you.

Last updated 3 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

sibbirius sibbirius Joined 30 Oct 2019

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.