-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Closed
Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.3 |
i just cloned symfony-standard and changed these two files
- app/Resources/views/default/index.html.twig
- src/AppBundle/Controller/DefaultController.php
in the template i just added {{form(form)}}
the controller looks like this
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Form\Extension\Core\Type as F;
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
$form = $this->get('form.factory')->createBuilder()
->add('field', F\ChoiceType::class,
[ 'choices' => ['a' => 'a', 'b' => 'b']
, 'expanded' => true
, 'multiple' => true
, 'attr' => ['class' => 'AAA']
, 'choice_attr' => ['class' => 'BBB', 'required' => true]
, 'required' => true
])
->getForm();
// replace this example code with whatever you need
return $this->render('default/index.html.twig', [
'base_dir' => realpath($this->getParameter('kernel.project_dir')).DIRECTORY_SEPARATOR,
'form' => $form->createView()
]);
}
}
In the html that is rendered i don't see the class BBB
or the required
on my checkboxes. My goal is to put required on all the checkboxes and then use javascript (something like https://stackoverflow.com/a/24862015) to validate that at least 1 is checked in a group.
HTML is rendered by FireFox 55.0.3
Metadata
Metadata
Assignees
Labels
No labels