symfonysymfony-2.6

get values of all selected checkboxes symfony2


<th scope="col">{{ d.id }} <input type="checkbox" value="{{ d.id }}" name="checkboxD" class="checker"></th>

how to get list of values from the selected checkbox ??

my controller action

        public function traiterAction() {
            $IDs = array();
            if ( $this->getRequest()->isMethod('POST') ) {

            $IDs = $this->getRequest()->get('checkboxD');
            }
            return $this->render('@EgovPoste/test.html.twig',array('ids'=>$IDs));
    }

Solution

  • You need to change the name to checkboxD[] . I hope that will help you