Problem
You want to create a radio button field for your Blade template.
Solution
Use the Form::radio()
method.
You’re only required to use the first argument, name.
[/c]c
This produces the following HTML.
[cc lang="html" escaped="true" width="700"]
<input name="single" type="radio" value="single">
But, radio buttons make the most sense when you have several with the same name, but different values. Specify the value with the second argument.
Now the value will either be ‘male’ or ‘female’.
If you want to default the value as checked, pass true as the third argument.
This adds the checked attribute to second radio button.
Finally, you can add additional attributes to the input field with the fourth argument.
Now the field has the class attribute.
Discussion
The appropriate radio button will automatically get checked based on any flash data.
If you redisplay the form because of errors, your radio button fields will retain what the user had previously.
Also, if you’ve bound a model to the form, it will pull the value from the model’s data. See Creating a New Model Based Form.
from Linux Hint https://ift.tt/3iHfKVd
0 Comments