Search Results

Search found 101 results on 5 pages for 'symfony2'.

Page 1/5 | 1 2 3 4 5  | Next Page >

  • Symfony2: automatically logging in users from their Windows session

    - by Paul Maclean
    In Symfony2 I have built an intranet. It currently uses the FOSUserBundle and an LDAP bundle to log users in, and I would like to add the functionality to log in user from their session in Windows. I found an NTLM script for PHP and an updated version of it, but I haven't been able to incorporate them into Symfony2. I also found an NTLM bundle for Symfony2, but it was written for an older version of Symfony and it is not maintained anymore. I was unable to rewrite it and get it to work. My question is; how could I automatically log in users from their Windows session in my Symfony2-app, in addition to the already present LDAP functionality? What would be the best and easiest way?

    Read the article

  • Doctrine2 Mutliple DBs without Symfony2?

    - by ehime
    Hey guys I know that using the Doctrinebundle in Symfony2 it is possible to instantiate multiple DB connections under Doctrine... $connectionFactory = $this->container->get('doctrine.dbal.connection_factory'); $connection = $connectionFactory->createConnection(array( 'driver' => 'pdo_mysql', 'user' => 'foo_user', 'password' => 'foo_pass', 'host' => 'foo_host', 'dbname' => 'foo_db', )); I'm curious if this is the case if you are using PURELY Doctrine though?, I've set up Doctrine via Composer like so... { "config": { "vendor-dir": "lib/" }, "require": { "doctrine/orm": "2.3.4", "doctrine/dbal": "2.3.4" } } And have been looking for my ConnectionFactory class but am not seeing it anywhere? Am I required to use Symfony2 to do this? Thanks!

    Read the article

  • Create a multicolor selectbox on Symfony2

    - by Ninsuo
    I try to create the following field : <select name="test"> <option value="1">a</option> <option value="2">b</option> <option value="3" style="font-weight: bold; color: red;">c</option> <option value="4">d</option> <option value="5">e</option> </select> This creates a 2-color selectbox : But in Symfony2, I do not know how to apply a class to a single option. If in my view I do : {{ form_widget(myForm.test, { 'attr': { 'class': 'red', } }) }} Or if in my form I do : $builder->add('test', 'choice', array( 'required' => true, 'choices' => array('a', 'b', 'c', 'd', 'e'), 'attr' => array('class' => 'red'), )); The attribute is stored into the <select> tag and apply to the whole selectable values. How do I apply a class to an <option> in Symfony2 ?

    Read the article

  • Symfony2 impersonation route parameters missing

    - by jaPa
    I receive an error when I change pages if I am impersonated as another user in Symfony2. It only happens when the route has additional parameters. There is no sign of route generation at the pointed line number. Controller action /** * @Route("/member/{id}", name="member_page") * @Template() */ public function memberAction($id) Error An exception has been thrown during the rendering of a template ("Some mandatory parameters are missing ("slug") to generate a URL for route "member_page".") in members.html.twig at line 2.

    Read the article

  • PHP app\console wont work trying to create bundle for Symfony2

    - by user3461632
    I have installed Symfony2 on a iis 7 server with PHP 5.3.21 and everything works ok ( the php, the symphony demo page ). I try to create my own helloWorld, as the tutorial says : php app/console generate:bundle I go Start-Run-CMD and put that line of code and it gives me back this : could not open input file : app/console and before anyone asks i am in the project directory when i perform this command I put the PHP directory to the System PATH but the problem persists.

    Read the article

  • Add CSS to Form Type is Symfony2

    - by Umair Iqbal
    I have an edit form, The form is made through symfony2 Form types. I checked the documentation but couldn't find any option for adding CSS to the form. The form display the data correctly and everything is fine what I want to do is to add styling to each field. My Edit Type is public function buildForm(FormBuilder $builder, array $options) { $builder ->add('id', 'hidden') ->add('patent_name', 'text', array('label' => 'Patent Name')) ->add('description', 'textarea', array('label' => 'Description', 'required' => false)) ->add('appln_auth','text', array('label' => 'Application Authorization')) ; } Anyone has any idea ho I can add css ? Thanks

    Read the article

  • Symfony2 & Twig - theming file upload widget

    - by Sacred Socks
    I have an Symfony2 edit form for an entity and one of the fields is for the user's profile picture. I'm trying to theme the Twig file upload widget so that the current picture set for the field is displayed above the file input. So far, I have: {% form_theme edit_form _self %} {% block field_widget %} {% set type = type|default('text') %} {% if type == 'file' %} <img src="{{ value }}" /> {% endif %} {{ block('form_widget_simple') }} {% endblock %} All works well except that the value variable is blank (which makes sense I guess). My question is how can I get hold of the path to the file? Is there a way to pick it out of the form values for the field? Could I perhaps pass it through as an option to the field? Srz if this is a dumb question, still pretty new to Symfony and Twig..

    Read the article

  • Symfony2 same form, different entities NOT related

    - by user1381537
    I'm trying to write one form for submitting against MySQL DB, but I can't get it working, I've tried a lot of things (separate forms, create an ->add('foo', new foo()) to a field, and trying to parse plain SQL with a normal HTML form is my only solution, which is obviously not the best. This is my DB structure: As you can see I need to insert the comments textarea to ticketcomments among the user who wrote it, etc. On crmentity the description field. Then on ticketcf the fields that I need to submit from form, are this (because you wont know if I don't tell you because of the field names): tcf.cf594 AS Type, tcf.cf675 AS Suscription, tcf.cf770 AS ID_PRODUCT, tcf.cf746 AS NotificationDate, tcf.cf747 AS ResponseDate, tcf.cf748 AS ResolutionDate, And, of course, every table needs to have the same ticketid id for the submitted form, so we can retrieve it with one simple query. It will be easy to do with plain SQL instead of using DQL and Symfony2 forms, but is not a good way to do it. Also, here's my "Ticket list" query, if you need it to have it more clear... SELECT t.ticketNo AS Ticket, t.title AS Asunto, t.status AS Estado, t.updateLog AS LOG, t.hours AS Horas, t.solution AS Solucion, t.priority AS Prioridad, tcf.cf594 AS Tipo, tcf.cf675 AS Suscripcion, tcf.cf770 AS IDPROD, tcf.cf746 AS F_Noti, tcf.cf747 AS F_Resp, tcf.cf748 AS F_Reso, CONCAT (cd.firstname, cd.lastname) AS Contacto, crm.description AS Descripcion, crm.crmid AS id FROM WbsGoclientsBundle:VtigerTroubletickets t INNER JOIN WbsGoclientsBundle:VtigerTicketcf tcf WITH t.ticketid = tcf.ticketid INNER JOIN WbsGoclientsBundle:VtigerContactdetails cd WITH t.parentId = cd.contactid INNER JOIN WbsGoclientsBundle:VtigerCrmentity crm WITH t.ticketid = crm.crmid WHERE t.parentId IN ( SELECT cd1.contactid FROM WbsGoclientsBundle:VtigerContactdetails cd1 WHERE cd1.accountid = ( SELECT cd2.accountid FROM WbsGoclientsBundle:VtigerContactdetails cd2 WHERE cd2.contactid = :contactid)) AND t.status <> \'Closed\' And also "Ticket details" query (which is not in DQL format yet, only SQL) is so simple, it only retrieve the comments field and createdtime from ticketcomments appended to this query so we have all the fields... Thank you. This is a test form, using troubletickets and ticketcomments, it's returning errores because I can't set a comments field because troubletickets doesn't has it, but I need that field to be submitted to ticketcomments ... VtigerTicketcommentsType <?php namespace WbsGo\clientsBundle\Form\Type; use Symfony\Component\Form\AbstractType, Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class VtigerTicketcommentsType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('ticketid') ->add('comments') ->add('ownerid') ->add('ownertype') ->add('createdtype') ; } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'WbsGo\clientsBundle\Entity\VtigerTicketcomments' )); } public function getName() { return 'comments'; } } OpenTicketType.php <?php namespace WbsGo\clientsBundle\Form; use Symfony\Component\Form\AbstractType, Symfony\Component\Form\FormBuilderInterface ; use WbsGo\clientsBundle\Form\Type\VtigerTicketcommentsType; use Symfony\Component\OptionsResolver\OptionsResolverInterface; class OpenTicketType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('title') ->add('priority') ->add('solution') ->add('comments', 'collection', array( 'type' => new VtigerTicketcommentsType() )) ; } public function setDefaultOptions(OptionsResolverInterface $resolver) { $resolver->setDefaults(array( 'data_class' => 'WbsGo\clientsBundle\Entity\VtigerTroubletickets' )); } public function getName() { return 'ticket'; } } TicketController.php <?php namespace WbsGo\clientsBundle\Controller; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use WbsGo\clientsBundle\Entity\VtigerTroubletickets; use WbsGo\clientsBundle\Entity\VtigerTicketcomments; use WbsGo\clientsBundle\Form\OpenTicketType; use Symfony\Component\HttpFoundation\Request; class TicketController extends Controller { public function indexAction() { $em = $this->getDoctrine()->getManager(); $tickets = $em ->getRepository('WbsGoclientsBundle:VtigerTroubletickets') ->findAllOpenByCustomerId($this->getUser()->getId()); $userdata = $this->getDoctrine()->getManager() ->getRepository('WbsGoclientsBundle:VtigerContactdetails') ->findContact($this->getUser()->getId()); return $this ->render('WbsGoclientsBundle:Ticket:index.html.twig', array('tickets' => $tickets, 'userdata' => $userdata)); } public function addAction() { $assets = $this->getDoctrine()->getManager() ->getRepository('WbsGoclientsBundle:VtigerAssets') ->findAssetByAccountId($this->getUser()->getId()); $assetlist = array(); foreach ($assets as $key => $v) { $assetlist[$key] = $key; } $form = $this->createForm(new OpenTicketType(), new VtigerTroubletickets()); return $this ->render('WbsGoclientsBundle:Ticket:add.html.twig', array('form' => $form->createView(), 'assets' => $assets,)); } } This is the error Symfony2 is returning Neither the property "comments" nor one of the methods "getComments()", "isComments()", "hasComments()", "_get()" or "_call()" exist and have public access in class "WbsGo\clientsBundle\Entity\VtigerTroubletickets". EDIT 2 This code is actually rendering my forms, but I need help in order to submit each XXXType form to its corresponding table. public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('descripcion') ->add('prioridad') ->add('solucion') ->add('comment', new VtigerTicketcommentsType() ) ->add('contacto') ->add('suscripcion') ->add('producto', 'entity', array( 'class' => 'WbsGo\clientsBundle\Entity\VtigerAssets', 'property' => 'assetname', 'empty_value' => '--SELECT--', 'query_builder' => function(\WbsGo\clientsBundle\Entity\VtigerAssetsRepository $repository) { //return $repository->findAssetByAccountId($this->customerId); return $repository->createQueryBuilder('a') ->select('a') ->where('a.account = (SELECT cd.accountid FROM WbsGoclientsBundle:VtigerContactdetails cd WHERE cd.contactid = ?1)') ->setParameter(1, $this->customerId); } ) ) ->add('hardware') ->add('backup') ->add('web') ->add('restore') ->add('customerId') ; } I also removed ->add('ticketid') from VtigerTicketcommentsType.php because it has relationship and is not needed. it's auto_incremental and must be generated once everything is submitted.

    Read the article

  • emberjs on symfony2 dev enviroment dont work propertly

    - by rkmax
    I've builded a app with symfony2 the app expose an REST Api. now i build a simple client for consuming app.coffee - app.js App = Em.Application.create ready: -> @.entradas.load() Entrada: Em.Object.extend() entradas: Em.ArrayController.create content: [] load: -> url = 'http://localhost/api/1/entrada' me = @ $.ajax( url: url, method: 'GET', success: (data) -> me.set('content', []) for entrada in data.data.objects me.pushObject DBPlus.Entrada.create(entrada) ) MyBundle:Home:index.html.twig <script type="text/x-handlebars" src="{{ asset('js/templates/entradas.hbs') }}"></script> <script src="{{ asset('js/libs/jquery-1.7.2.min.js') }}"></script> <script src="{{ asset('js/libs/handlebars-1.0.0.beta.6.js') }}"></script> <script src="{{ asset('js/libs/ember-1.0.pre.min.js') }}"></script> <script src="{{ asset('js/app.js') }}"></script> the problem here is when i run on dev enviroment and link the template like <script type="text/x-handlebars" src="{{...}}"> the app dont work, nothing show but works fine over prod enviroment. he only way that works on dev enviroment is inline template MyBundle:Home:index.html.twig <script type="text/x-handlebars"> {% raw %} <ul class="entradas"> {{#each App.entradas}} <li class="entrada">{{nombre}}</li> {{/each}} </ul> {% endraw %} </script> can explain why this behavoir? Note: I disabled the debug profiler toolbar, and nothing

    Read the article

  • Symfony2 - PdfBundle not working

    - by ElPiter
    Using Symfony2 and PdfBundle to generate dynamically PDF files, I don't get to generate the files indeed. Following documentation instructions, I have set up all the bundle thing: autoload.php: 'Ps' => __DIR__.'/../vendor/bundles', 'PHPPdf' => __DIR__.'/../vendor/PHPPdf/lib', 'Imagine' => array(__DIR__.'/../vendor/PHPPdf/lib', __DIR__.'/../vendor/PHPPdf/lib/vendor/Imagine/lib'), 'Zend' => __DIR__.'/../vendor/PHPPdf/lib/vendor/Zend/library', 'ZendPdf' => __DIR__.'/../vendor/PHPPdf/lib/vendor/ZendPdf/library', AppKernel.php: ... new Ps\PdfBundle\PsPdfBundle(), ... I guess all the setting up is correctly configured, as I am not getting any "library not found" nor anything on that way... So, after all that, I am doing this in the controller: ... use Ps\PdfBundle\Annotation\Pdf; ... /** * @Pdf() * @Route ("/pdf", name="_pdf") * @Template() */ public function generateInvoicePDFAction($name = 'Pedro') { return $this->render('AcmeStoreBundle:Shop:generateInvoice.pdf.twig', array( 'name' => $name, )); } And having this twig file: <pdf> <dynamic-page> Hello {{ name }}! </dynamic-page> </pdf> Well. Somehow, what I just get in my page is just the normal html generated as if it was a normal Response rendering. The Pdf() annotation is supposed to give the "special" behavior of creating the PDF file instead of rendering normal HTML. So, having the above code, when I request the route http://www.mysite.com/*...*/pdf, all what I get is the following HTML rendered: <pdf> <dynamic-page> Hello Pedro! </dynamic-page> </pdf> (so a blank HTML page with just the words Hello Pedro! on it. Any clue? Am I doing anything wrong? Is it mandatory to have the alternative *.html.twig apart from the *.pdf.twig version? I don't think so... :(

    Read the article

  • Symfony2 Entity to array

    - by Adriano Pedro
    I'm trying to migrate my flat php project to Symfony2, but its coming to be very hard. For instance, I have a table of Products specification that have several specifications and are distinguishables by its "cat" attribute in that Extraspecs DB table. Therefore I've created a Entity for that table and want to make an array of just the specifications with "cat" = 0... I supose the code is this one.. right? $typeavailable = $this->getDoctrine() ->getRepository('LabsCatalogBundle:ProductExtraspecsSpecs') ->findBy(array('cat' => '0')); Now how can i put this in an array to work with a form like this?: form = $this ->createFormBuilder($product) ->add('specs', 'choice', array('choices' => $typeavailableArray), 'multiple' => true) Thank you in advance :) # Thank you all.. But now I've came across with another problem.. In fact i'm building a form from an existing object: $form = $this ->createFormBuilder($product) ->add('name', 'text') ->add('genspec', 'choice', array('choices' => array('0' => 'None', '1' => 'General', '2' => 'Specific'))) ->add('isReg', 'choice', array('choices' => array('0' => 'Material', '1' => 'Reagent', '2' => 'Antibody', '3' => 'Growth Factors', '4' => 'Rodents', '5' => 'Lagomorphs'))) So.. in that case my current value is named "extraspecs", so i've added this like: ->add('extraspecs', 'entity', array( 'label' => 'desc', 'empty_value' => ' --- ', 'class' => 'LabsCatalogBundle:ProductExtraspecsSpecs', 'property' => 'specsid', 'query_builder' => function(EntityRepository $er) { return $er ->createQueryBuilder('e'); But "extraspecs" come from a relationship of oneToMany where every product has several extraspecs... Here is the ORM: Labs\CatalogBundle\Entity\Product: type: entity table: orders__regmat id: id: type: integer generator: { strategy: AUTO } fields: name: type: string length: 100 catnumber: type: string scale: 100 brand: type: integer scale: 10 company: type: integer scale: 10 size: type: decimal scale: 10 units: type: integer scale: 10 price: type: decimal scale: 10 reqcert: type: integer scale: 1 isReg: type: integer scale: 1 genspec: type: integer scale: 1 oneToMany: extraspecs: targetEntity: ProductExtraspecs mappedBy: product Labs\CatalogBundle\Entity\ProductExtraspecs: type: entity table: orders__regmat__extraspecs fields: extraspecid: id: true type: integer unsigned: false nullable: false generator: strategy: IDENTITY regmatid: type: integer scale: 11 spec: type: integer scale: 11 attrib: type: string length: 20 value: type: string length: 200 lifecycleCallbacks: { } manyToOne: product: targetEntity: Product inversedBy: extraspecs joinColumn: name: regmatid referencedColumnName: id HOw should I do this? Thank you!!!

    Read the article

  • symfony2.4 ajax call update or set session issues

    - by user3797283
    i have an issue with symfony2 when i use ajax to set session, hope u pro guys can help me. here is my controller code: //show month event list public function indexAction() { if ($this->getRequest()->isXmlHttpRequest()) { $paging = $this->getRequest()->get("nom"); $session = $this->getRequest()->getSession(); if ($paging) { //if $paging is set, then that's a click pager ajax event //(not 1st time load) $year = $paging; $session->set('year', $year); } else { //$paging is null, it's the first time page load $year = (new \DateTime())->format("Y"); $session->set('year', $year); } $repository = $this ->getDoctrine() ->getManager() ->getRepository('HycAccountBundle:MonthEvent'); $annuallist = $repository->monthListByYear($year); $jsonlist = json_encode($annuallist); return new Response($jsonlist); } //this part is to return entity to twig for using after $em = $this->getDoctrine()->getManager(); $allimages = $em->getRepository('HycAccountBundle:TypeImage') ->findAll(); return $this->render('HycAccountBundle:Account:index.html.twig', array('allimages' => $allimages)); } here is my twig code: <script type="text/javascript"> $(function() { $(document).ready(function (){ jQuery.ajax({ type: 'GET', cache: false, url: "{{ path('hyc_account_homepage') }}", success: function(data, textStatus, jqXHR) { alert({{app.session.get('year')}}); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //!!!!!!!!! here i can get year 2014 !!!!!!!!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }, error:function (){ alert('error!'); } }); return false; }); }); </script> but when i click pager part, for example, i click year 2013, then ajax call will return a number (data: 'nom=' + num) to controller, but there i reset session value to num normally, but i cant get alert correct session (it's always 2014 as the 1st time) here is the code ajax, almost same as above: <script type="text/javascript"> $(document).ready(function(){ //after paging, reload month $('#page-selection').bootpag({ total: 3000, page: 2014, maxVisible: 5 }).on('page', function(event, num){ jQuery.ajax({ type: 'GET', url: "{{ path('hyc_account_homepage') }}", data: 'nom=' + num, success: function(data, textStatus, jqXHR) { alert({{app.session.get('year')}}); //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! //here is the problem, it's always 2014, not set again !!!!!!!! //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! }, error:function (){ alert('error!'); } }); return false; }); }); </script> hope u guys help me, thanks in advance, i've tried for almost 1 day and looked for almost all in google but find nothing = =

    Read the article

  • how to use console use in Symfony2

    - by Elzo Valugi
    I found the console and run it like this: root@valugi-laptop:/var/www/sandbox/hello# php console Symfony version 2.0.0-DEV - hello Usage: Symfony [options] command [arguments] Options: --help -h Display this help message. --quiet -q Do not output any message. --verbose -v Increase verbosity of messages. --version -V Display this program version. --color -c Force ANSI color output. --no-interaction -n Do not ask any interactive question. --shell -s Launch the shell. Available commands: help Displays help for a command (?) list Lists commands assets :install bundle :pharize container :graphviz doctrine :generate-proxies init :application :bundle router :debug Displays current routes for an application :dump-apache But I cannot run any of those commands. I am trying like this: php console Symfony -h But I get [InvalidArgumentException] Command "Symfony" is not defined. Any suggestions?

    Read the article

  • Symfony2 trans_default_domain is not working

    - by user1069843
    At the end of http://symfony.com/doc/current/book/translation.html#twig-templates I read about {% trans_default_domain "app" %} to set a translation domain for a whole template. But for me it does not work. Calling app/console translation:extract de --dir=src/ --output-dir=app/Resources/translations --output-format=xliff --keep Just puts all messages in the messages.de.xliff file. But if I set the domain manually for a given label like {{ label.name|trans({}, 'app') }} And execute the same extract command as above, then I get a new file app.de.xliff Is there anything more to do when using trans_default_domain?

    Read the article

  • Correct way to set the driverOptions for Doctrine DBAL configuration in symfony2

    - by yesIcan
    I have set driverOptions in the config file as mentioned in the doctrine DBAL documentation. But this gives and error 1/1 InvalidConfigurationException: Unrecognized options "driverOptions" under "doctrine.dbal.connections.pdoDevCon" My config file is dbal: default_connection: pdoDevCon connections: pdoDevCon: driver: %dev_database_driver% # < host: %dev_database_host% # | port: %dev_database_port% # | Defined in user: %dev_database_user% # | password: %dev_database_password% # < charset: UTF8 driverOptions: {3: 2} mapping_types: enum: string set: string orm: auto_generate_proxy_classes: %kernel.debug% pdoDevCon: connection: pdoDevCon mappings: AcmeDemoBundle: ~ AcmeHelloBundle: ~ I am using PDO::ATTR_ERRMODE as 3 PDO::ERRMODE_EXCEPTION as 2, it does not work even if i use the strings.

    Read the article

  • Symfony2 and RabbitMqBundle. Can`t publish a message

    - by Gabriel Filipiak
    I am trying to use syfmony2 framework with RabbitMqBundle from here: https://github.com/videlalvaro/RabbitMqBundle I am sure that my rabbitmq server is up and running and I am doing the configuration and publishers code accordingly to the docs delivered on github. Unfortunately I can`t add any message to the queue. I am sure that my rabbitmq server is up and running. I have queue named accordingly to the symfony configuration file. Have anyone got any clue what is wrong? Thanks in advance for any suggestions.

    Read the article

  • Symfony2 Theming form generated by embedded controller action

    - by user1112057
    I am generating the form in embedded controller action. And now i have faced the following problem. The Form Theming is not working in that case. So what i have: The tempalte "page.html.twig" {% block content %} {% render 'MyBundle:Widget:index' %} {% endblock %} The indexAction() creates the form and rendering another template "form.html.twig" which is normally renders a form using form_row, form_rest and so on. So, now i am trying to customize form theming, and here is my problem. When i put the code {% form_theme form _self %} in the page.html.twig, i got an error the the form variable does not exists. And its correct, the form var is created later in the embedded controller. But when i put the theming code in embedded template "form.html.twig", i got another error "Variable "compound" does not exist" {% block form_label %} {% spaceless %} {% if not compound %} {% set label_attr = label_attr|merge({'for': id}) %} {% endif %} {% if required %} {% set label_attr = label_attr|merge({'class': (label_attr.class|default('') ~ ' required')|trim}) %} {% endif %} {% if label is empty %} {% set label = name|humanize %} {% endif %} <label{% for attrname, attrvalue in label_attr %} {{ attrname }}="{{ attrvalue }}"{% endfor %} {% if attr.tooltip is defined %}title="{{ attr.tooltip }}"{% endif %}>{{ label|trans({}, translation_domain) }}{% if required %}<span>*</span>{% endif %}</label> {% endspaceless %} {% endblock form_label %} This part of code was copied from this file https://github.com/symfony/symfony/blob/2.1/src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig So tried someone to do something like this?

    Read the article

  • Symfony2 Setting a default choice field selection

    - by Mat
    I am creating a form in the following manner: $form = $this->createFormBuilder($breed) ->add('species', 'entity', array( 'class' => 'BFPEduBundle:Item', 'property' => 'name', 'query_builder' => function(ItemRepository $er){ return $er->createQueryBuilder('i') ->where("i.type = 'species'") ->orderBy('i.name', 'ASC'); })) ->add('breed', 'text', array('required'=>true)) ->add('size', 'textarea', array('required' => false)) ->getForm() How can I set a default value for the species listbox? Thank you for your response, I apologise, I think I should rephrase my question. Once I have a value that I retrieve from the model, how do I set that value as SELECTED="yes" for the corresponding value in the species choice list? So, that select option output from the TWIG view would appear like so: <option value="174" selected="yes">Dog</option>

    Read the article

  • How to embed a precharged collection of non-entity forms in symfony2

    - by metalvarez
    I want to embed a collection of precharged non-entity forms, here is the code, first is the parent form buildForm method. public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add("example1")->add("example2"); $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { /*some logic to do before adding the collection of forms*/ $form->add('aclAccess', 'collection', array( 'type' => new ChildFormType(), 'allow_add' => true, 'mapped' => false, 'data' => /* I dont know how to precharge a collection of non-entity forms*/ )); }); } now the child form public function buildForm (FormBuilderInterface $builder, array $options) { $builder->add("test1", "text", array("read_only" => true, "data" => "test")); $builder->->add("test2", "choice", array( 'choices' => array('opt1' => 'Opt1', 'opt2' => 'Opt2'), 'multiple' => true, 'expanded' => true )); } so basicly i want to manage those child options in the test2 field as separated forms, each option group will depend on the value of the test1 field, i know this can be done by coding everythin in twig without form classes but i think having form classes its the best practice to run phpunit test, for maintainability, etc ...

    Read the article

  • Symfony2: update query with query builder

    - by Ichigo Kurosaki
    This is my query $id contains primary key and $status contains new status public function updateStatus($id,$status) { $qb=$this-createQueryBuilder('b') -update() -set('b.status',$status) -where('b.id='.$id); echo $qb; return $qb-getQuery() -getResult(); } Problem I am facing is [Semantical Error] line 0, col 56 near 'Complete WHERE': Error: 'Complete' is not defined.

    Read the article

  • How to set up default value in symfony2 select box with data from database

    - by user172409255
    I have this code ->add('user', 'entity', array( 'class' => 'Acme\Entity\User', 'query_builder' => function(EntityRepository $er) use ($options) { return $er->createQueryBuilder('u') ->orderBy('u.name', 'ASC'); }, 'data' => $option['id'] )) Its not working public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('description') ->add('user', 'entity', array( 'class' => 'Acme\Entity\User', 'query_builder' => function(EntityRepository $er) use ($options) { return $er->createQueryBuilder('u'); }, 'preferred_choices' => array('2') )) ; }

    Read the article

  • Adding custom query to paginator (KNP Paginator) in Symfony2?

    - by Unni
    I have the following query , how to write these query in Symfony2 SELECT Inventory_Stock.id, Inventory_Stock.quantity, SUM(InventoryUsage.quantity) ,Inventory_Stock.quantity - SUM(InventoryUsage.quantity) AS Stock FROM Inventory_Stock LEFT JOIN InventoryUsage ON Inventory_Stock.id = InventoryUsage.InventoryStock_id WHERE Inventory_Stock.id = 26 OR Inventory_Stock.id = 27 GROUP BY Inventory_Stock.id ORDER BY Stock DESC I need to paginate this as well Would be great if any one could help me out as this has been pulling my hair out for couple of days.

    Read the article

  • How can one cache bust files referenced in a LESS file when using Symfony2, Twig, and Assetic?

    - by user3719083
    I have a web site built on Symfony2 which uses twig templates, LESS, and assetic. In order to cache bust assets, I'm simply using this in my config.yml: framework: templating: engines: ['twig'] assets_version: 'asset-version-here' And then I use the asset() function to load the asset and the cache busting is handled for me. However, the concern I have is when I load my LESS (css) file, there are references to other files, and I would like to know how these files can be cache busted as well. Example: .someSelector { background:url('../images/filename.png'); } How can I make sure that the referenced file, filename.png is cache busted upon deployment? The asset files referenced in Twig using asset() are cache busted automatically upon deployment (I use a deployment script hook that updates the assets_version in the framework's config), but those referenced in a stylesheet are not. How can I do this?

    Read the article

  • open_basedir problems with APC and Symfony2

    - by Stephen Orr
    I'm currently setting up a shared staging environment for one of our applications, written in PHP5.3 and using the Symfony2 framework. If I only host a single instance of the application per server, everything works as it should. However, if I then deploy additional instances of the application (which may or may not share the exact same code, dependent on client customisations), I get errors like this: [Tue Nov 06 10:19:23 2012] [error] [client 127.0.0.1] PHP Warning: require(/var/www/vhosts/application1/httpdocs/vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php): failed to open stream: Operation not permitted in /var/www/vhosts/application2/httpdocs/app/bootstrap.php.cache on line 1193 [Tue Nov 06 10:19:23 2012] [error] [client 127.0.0.1] PHP Fatal error: require(): Failed opening required '/var/www/vhosts/application1/httpdocs/app/../vendor/doctrine-common/lib/Doctrine/Common/Annotations/AnnotationRegistry.php' (include_path='.:/usr/share/pear:/usr/share/php') in /var/www/vhosts/application2/httpdocs/app/bootstrap.php.cache on line 1193 Basically, the second site is trying to require the files from the first site, but due to open_basedir restrictions it can't do that. I'm not willing to disable open_basedir as that is only masking the problem instead of solving it, and creates a dependency between applications that should not be present. I initially believed this was related to a Symfony2 error, but I've now tracked it down to an issue with APC; disabling APC also solves the error, but I'm concerned about the performance impact of doing so. Does anyone have any suggestions on what I might be able to do?

    Read the article

  • what are the most essential bundles in symfony2?

    - by user
    this question but i hope it does not, i'll try my best to make clarify it I'm new to symfony2 but not to php, as far as i know, everything in symfony2 is bundles. Being a django guy, i know that the essential apps are: south Django-Debug-Toolbar Haystack Search Django Admin Tools (maybe) fabric the registration and user profile app (unless you decide to use django-userena) Piston I'm not going to make a longer list, you get the point. I know 2 essential apps for symfony2 so far the admin generator and FOSUserBundle. So what are other must have bundles?

    Read the article

1 2 3 4 5  | Next Page >