symfony-2.1

How to get data from a form in symfony2

喜夏-厌秋 提交于 2019-12-24 23:18:46
问题 I have a method : public function showCategoryAction($id, $page, Request $request){ $em = $this->getDoctrine()->getManager(); $repositoryProduct = $em->getRepository('ShopDesktopBundle:Product'); $aFilter = array(); $form = $this->get('form.factory')->createNamedBuilder('', 'form', null, array( 'csrf_protection' => false, )) ->setMethod('GET') ->add('minimPrice', 'text', array('mapped' => false, 'label' => 'De la :' , 'attr'=> array( 'placeholder'=>'Minim price', 'class'=>'form-control'))) -

File Uploads with Doctrine

泪湿孤枕 提交于 2019-12-24 15:14:26
问题 I am trying to upload files with Doctrine in Symfony2. I followed all the steps in this tutorial tutorial but whene I submit my form I get no errors but the file is not uploaded and the path in the table "document" is null. This is my entity <?php namespace projet\ClasseBundle\Entity; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; /** * Projet * * @ORM\Table() * @ORM\Entity(repositoryClass="projet\ClasseBundle\Entity\ProjetRepository") * @ORM

Defining custom twig form block for errors rendering

夙愿已清 提交于 2019-12-24 11:41:36
问题 I'm trying to define a specific new block for form field errors rendering, keeping form_errors unchanged for common errors rendering. # Twig Configuration twig: debug: %kernel.debug% strict_variables: %kernel.debug% form: resources: - 'ApplicationMyBundle:Main:form/customFormTheme.html.twig' In customFormTheme.html.twig I overwrite a few blocks copied from form_div_layout.html.twig plus I added the folloowing new one. {% block field_errors %}{% spaceless %} {% if errors|length > 0 %} <ul

Repeat the same fields in a form

心已入冬 提交于 2019-12-24 07:49:09
问题 What is the best way of repeating the same form fields within a form? I'd like the user to submit multiple Name / Phone number rows. class contactType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder ->add('name1', 'text') ->add('phone1', 'text'); ->add('name2', 'text') ->add('phone2', 'text'); ->add('name3', 'text') ->add('phone3', 'text'); ....etc } } Ideally, I would like the user to enter as many fields as he wants... 1- Is there a

Symfony2.1 form date field: Argument 1 passed to … must be an instance of DateTime

荒凉一梦 提交于 2019-12-24 03:05:27
问题 My Entity: /** * @var \DateTime $publishedAt * * @ORM\Column(name="published_at", type="date") * * @Assert\Date() */ private $publishedAt; /** * Set publishedAt * * @param \DateTime $publishedAt * @return MagazineIssue */ public function setPublishedAt(\DateTime $publishedAt) { $this->publishedAt = $publishedAt; return $this; } /** * Get published_at * * @return \DateTime */ public function getPublishedAt() { return $this->publishedAt; } My form builder: $builder->add('publishedAt'); My view:

How to upgrade symfony2 version?

橙三吉。 提交于 2019-12-24 01:48:16
问题 Is there a easy way to upgrade your symfony2.1.6 to 2.1.7 via command line or so? I am using composer.json 回答1: Download composer.phar and then run in the symfony folder php composer.phar update If you get some errors try removing first the vendors and try again. rm - R vendor/* 来源: https://stackoverflow.com/questions/14924867/how-to-upgrade-symfony2-version

Symfony2 Jobeet tutorial day 3 error invalid mapping

这一生的挚爱 提交于 2019-12-23 19:43:24
问题 When I generate bundle entities with code php app/console doctrine:generate:entities EnsJobeetBundle I'm getting this error [Doctrine\Common\Persistence\Mapping\MappingException] Invalid mapping file 'Ens.JobeetBundle.Entity.Affiliate.orm.yml' for class 'Ens\JobeetBundle\Entity\Affiliate'. This is Affiliate.orm.yml file: Ens\JobeetBundle\Entity\Affiliate: type: entity table: affiliate id: id: type: integer generator: { strategy: AUTO } fields: url: type: string length: 255 email: type: string

PHP Fatal error: Uncaught exception PharException with message manifest

岁酱吖の 提交于 2019-12-23 15:20:13
问题 while trying to install composer.phar through command line , got an error PHP Fatal error: Uncaught exception 'PharException' with message manifest cannot be larger than 100 mb in phar please support me to solve this problem, i am trying to installing symfony2.1 回答1: It appears you got a corrupted phar for some reason. Try downloading a new one from https://getcomposer.org/download/ - if the CLI instructions do not work out for you you can just download the last snapshot by hand from https:/

Issue with the Entity Manager and phpunit in Symfony 2

戏子无情 提交于 2019-12-23 10:05:59
问题 I have an issue with my Entity Manager in phpunit. This is my test : public function testValidChangeEmail() { $client = self::createAuthClient('user','password'); $crawler = $client->request('GET', '/user/edit/30'); $crawler = $client->submit($crawler->selectButton('submit')->form(array( 'form[email]' => 'new@email.com', ))); /* * With this em, this work perfectly * $em = $client->getContainer()->get('doctrine.orm.entity_manager'); */ $user = self::$em->getRepository('MyBundle:User')-

Implementing a friends list in Symfony2.1 with Doctrine

耗尽温柔 提交于 2019-12-23 05:39:07
问题 I want to implement friends list of particular user in Symfony2.1 and Doctrine. Lets say friends table: User1 User2 Status //0-pending request,1-accepted A B 0 A C 1 D A 1 E A 1 Now I want to get A 's friends name in the list. For this SQL query can be implemented using UNION as read in many other answers. But I want to implement this in doctrine query builder. One option is like query separately for two columns and combine the result and sort. But this takes more time to execute and get