Thursday, June 30, 2016

Selected value in Twig

The resolution was to force conversion of int to string:
{{ form_widget(form.item1, {value: myvariable ~ ""}) }}
Check this out :

http://stackoverflow.com/questions/25326400/selected-value-in-twig

Tuesday, June 28, 2016

Explicitly print CSRF token field instead of form_rest(form)

Request option for Guzzle

Types doctrine

How to catch Exception in symfony 2 ?

You should take care for the exceptions that could be raised:
try{
  $em = $this->getDoctrine()->getManager();
  $em->persist($entity);
  $em->flush();

  return $this->redirect($this->generateUrl('target page'));

} catch(\Doctrine\ORM\ORMException $e){
  // flash msg
  $this->get('session')->getFlashBag()->add('error', 'Your custom message');
  // or some shortcut that need to be implemented
  // $this->addFlash('error', 'Custom message');

  // error logging - need customization
  $this->get('logger')->error($e->getMessage());
  //$this->get('logger')->error($e->getTraceAsString());
  // or some shortcut that need to be implemented
  // $this->logError($e);

  // some redirection e. g. to referer
  return $this->redirect($this->getRequest()->headers->get('referer'));
} catch(\Exception $e){
  // other exceptions
  // flash
  // logger
  // redirection
}

return $this->render('MyTestBundle:Article:new.html.twig', array(
  'entity' => $entity,
  'form'   => $form->createView(),
));


New in Symfony 2.6: New shortcut methods for controllers

Sunday, June 19, 2016

Select2 4.0 placeholder undefined


Answer form stackoverflow

down voteaccepted
in this example if we delete || repo.text from formatRepoSelection it will not work. Because the repo.text is placeholder.
P.S. select2 4.0 do not need to empty option tag for placeholder working

Source : http://stackoverflow.com/questions/30302329/select2-4-0-placeholder-undefined

Friday, June 3, 2016

intl-tel-input-french-translation

intl-tel-input-french-translation

Check this out : https://jsfiddle.net/9yvdzv0a/2/