Issue 1:
I am running Symfony 4.2 and trying to create two Bootstrap 3 radio buttons. Here is the HTML for what I want to create:

<div class="btn-group btn-group-justified" data-toggle="buttons">
<label class="btn btn-lg btn-default">
<input type="radio" name="inquiry[flexDates]" value="yes">YES
</label>
<label class="btn btn-lg btn-default">
<input type="radio" name="inquiry[flexDates]" value="no">NO
</label>
</div>

This is my form builder code:

$builder
->add('flexDates', ChoiceType::class, [
'choices' => [
'Yes' => 'yes',
'No' => 'no',
],
'required' => false,
'empty_data' => '',
'expanded' => true, // these two options (expanded = true and
'multiple' => false, // multiple = false) make it a radio button
])

I have the Bootstrap 3 theme (bootstrap_3_layout.html.twig) installed and have tried various combinations of form_row(), form_label() and form_widget(). I've set attr and label_attr in several different ways,

but I cannot figure out how to generate the HTML above. There always seem to be extra <div>s or HTML that causes it to display incorrectly.

The HTML is part of a hard-coded form that has been working fine and I'm trying to convert it to a Twig template. Converting all the other fields was simple, but I've wasted nearly a day just trying to duplicate the radio buttons.

It seems like it should be easy, but how to do this is not clear from any of the documentation or examples I've been able to find.

I've tried creating my own block widget, but I can't figure out how to make the <label> include the <input> (instead of before or after). In order to make things work, the label must wrap around the input.

There is a {% block checkbox_radio_label %} defined in the bootstrap_3_layout.html.twig file that is close to what I need, but I cannot get it to work. It uses {{ widget|raw }}, but Symfony gives me a variable "widget" does not exist error when I try to use it.

So far, the information at https://symfony.com/doc/current/form/form_customization.html has been more confusing than helpful. I've been using Twig for years and have been able to do almost anything else, but this problem has me stumped. I know I could write my own custom filter, but it seems like there should be an easier way.

Issue 2:
Working on some internal code, I was having trouble understanding certain error messages. The main reason was because I wrote a "parameter" instead of "parameters". To save others some time, I wanted to show a nice possible alternative value that is allowed instead. I know that Symfony has a lot of those messages and they add value to the Developer Experience.

So I wanted to implement this and it occurred to me how often there was code duplication! I've done a very basic search for "Did you mean" and got 2 pages of which not all contained the actual implementation. There's some additional implementations to be found all around the code base but all come down to 1 thing, suggesting alternatives.

I think it would be a great addition to have a generic way to not only generate alternative suggestions within Symfony, but also for people who want to implement the DX concept in their own applications or libraries. I would imagine this to be a tiny component compared to others which could (for now) provide the following:

// just an example, no idea how this would be named or if both cases are needed
use Symfony\Component\Alternative\ManyAlternatives;
use Symfony\Component\Alternative\SingleAlternative;

$possibleOptions = ['foo', 'foobar', 'bar'];

echo implode(', ', ManyAlternatives::match(['fo'], $possibleOptions));
// foo, foobar

echo SingleAlternative::match(['fo'], $possibleOptions);
// foo

// or optionally with a custom value resolving
echo ManyAlternatives::match(
new Definition('foo'),
$possibleOptions,
function (Definition $d) { return $d->getName(); }
);