symfony-forms

Symfony alternate new action

人走茶凉 提交于 2020-01-05 07:34:48
问题 I have a server where I need to store some images. Now the images can be either uploaded or created on the fly let us say just by adding some text to some default picture(So I made a file MakenewForm.php for that) . The table in my database stores filename on the local filesystem. Now upload is simple, I can just use the default _new action for that. For creating picture, I made a new action, say makenew . new and makenew both are diplayed on the list view. I copied newSuccess.php to

Symfony File Upload In Edit Form

丶灬走出姿态 提交于 2020-01-05 05:00:33
问题 I have the following User Entity /** * @ORM\Entity */ class User { /** * @ORM\Column(type="integer") * @ORM\Id * @ORM\GeneratedValue(strategy="AUTO") */ private $id; /** * @ORM\Column(name="name", type="string", length=100, nullable=false) */ private $name; /** * @ORM\Column(type="string", name="picture", nullable=true) * @Assert\Image * @Assert\File(maxSize = "2M") */ private $picture; /** * Get id * * @return integer */ public function getId() { return $this->id; } /** * Set name * * @param

Payum Bundle : How to change the view of capture action in symfony2

社会主义新天地 提交于 2020-01-04 04:30:14
问题 I am using PAYUM Bundle for the payment gateway integration, and its basic example is working fine, But now I want integrate the payum bundle in application by changing the payum capture action layout and adding extra field payment detail entity. PAYUM BUNDLE with AUTHORIZE.NET GATEWAY. Please can anyone help me out. Thanks all in advance. 回答1: The payum templates is not kept in the bundle but in the payum lib itself. Standard templates inheritance does not work here. There is no simple way

symfony unit tests: add/modify form action

假如想象 提交于 2020-01-04 04:30:09
问题 I have a form, without action (is submitted with javascript) and I'm trying to write a unit test for it, but it fails because "action" attribute is missing: InvalidArgumentException : Current URI must be an absolute URL (""). There is a way to do add it in unit tests or modify the html content using the crawler? <form id="form_search_page"> <input type="text" name="keyword" value="" /> <button type="submit" name="searchBtn" id="searchBtn">Search</button> </form> $client = $this->makeClient

How to use Repository custom functions in a FormType

感情迁移 提交于 2020-01-04 03:18:19
问题 The problem I'm facing is I have to create a selectbox in a form that holds all the parent entities (Category Entity). Now i managed to do this with: $builder->add('parent', 'entity', array( 'class' => 'KprCentarZdravljaBundle:Category', 'query_builder' => function($repository) use ($param, $catID) { return $repository->createQueryBuilder('p') ->where('p.id != :id AND p.parent = :parent') ->setParameters(array('id' => $param, 'parent' => $catID));}, 'property' => 'name', 'required' => false,

Symfony 2.1 validator does not see mime-type

眉间皱痕 提交于 2020-01-03 17:18:05
问题 I'm working on Symfony 2.1 where i'm adding images to the default fosUserBundle User entity. On top of my entity I have this: use FOS\UserBundle\Entity\User as BaseUser; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\HttpFoundation\File\UploadedFile; /** * @ORM\Entity * @ORM\HasLifecycleCallbacks * @ORM\Table(name="users") */ class User extends BaseUser Next the concerning field: /** * @ORM\Column(nullable=true) * @Assert\File

How to bind a array with a single data to a form using the Action file in Symfony

旧巷老猫 提交于 2020-01-03 04:59:08
问题 I need to add a variable to be displayed as a default in the form in the widget area, I have set a filter to select a single value according to a different name in the dropdown. i have set the selected data to a session. and from that session i have taken that data to the action file. I want to display the selected data in the form dropdown with out creating a submit event. the form is displayed below public function configure() { //the dropdown $cost_range[''] = '-- Please select --'; for (

Assign many items to one category - OneToMany Relation

送分小仙女□ 提交于 2020-01-03 03:18:24
问题 I want to assign many items to one category. I'm using Symfony 2.6.7. I'm not at the owning side here. If I open this URI: /category/2/assign [x] Item 1 [x] Item 2 (Save Button) I have the possibility to chose many items with checkboxes. This is my db table "Item", where I want to connect the both: id | category_id It is an OneToMany relation, where One = Category and Many = Items. How can I assign the both here? It is already working, when I edit one item and than select a category to this

Cloning object after getting data from a form in Symfony2

馋奶兔 提交于 2020-01-02 07:21:11
问题 I'm sure I'm missing something very basic here. I have a form, and when the user updates the fields of the form I don't want to update the underlying entity but want to create a new entity with the new values. To clone Doctrine entities I followed the indication here. So my code is (let's say I want to clone the object with id=3: $id = 3; $storedBI = $this->getDoctrine() ->getRepository('AppBundle:BenefitItem') ->find($id); $form = $this->createForm(new BenefitItemFormType(), $storedBI);

Symfony 2.6 - render individual choice field (radio, checkbox) by name

假如想象 提交于 2020-01-01 02:46:26
问题 How can I render an individual field (single radio/checkbox input field) in Twig in Symfony 2.6? Let's say I have a simple form: class TransportType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('transport', 'choice', array( 'choices' => array( 'road' => 'Car/bus', 'train' => 'Train', ), 'expanded' => true, 'multiple' => false )); } In previous Symfony2 versions I could just use: {{ form_widget(form.transport.road) }} {{ form