Tagged Questions
1
vote
1answer
17 views
Symfony 2.3 Entity Boolean Property Allow Only One Row to be True
This should be pretty easy, but I can't seem to find the answer...
What I'm trying to do is create a page bundle; that parts been pretty easy. I've added an isHome column to my database. Basically I ...
0
votes
2answers
23 views
Symfony 2 “findBy” a mapped entity parameter into controller
I'm new with Symfony2 and i would like to know whether there is a way to use the "findBy" with a param which is present only in a mapped entity.
This is my snippet controller:
$prods = ...
0
votes
1answer
34 views
Symfony 2 - Twig can't access to correct mapped entity objects
I'm new with Symfony
There is a simple method indexAction in my controller class:
function indexAction()
{
$em = $this->getDoctrine()
->getEntityManager();
...
1
vote
1answer
34 views
PreUpdate cascade entity persist symfony 2.3
I have a bit of problems with PreUpdate HasLifecycleCallbacks.
I have an entity, let say "A" with have a OneToOne relation with the entity "B".
So I have:
/**
* @ORM\Entity()
* ...
0
votes
1answer
23 views
symfony2 - default value for “entity” field?
i am creating a form field ,this is correct in my project .
enter code here
role:
type: entity
attributs:
class: 'SystemUserBundle:Group'
property: name
expanded: ...
0
votes
1answer
32 views
FOSUserBundle: Update entity after registration
In order to register, users have to select a their account name created by my moderators. That means that a moderators have to create an account name before the user registers.
To do so, I made a ...
0
votes
1answer
27 views
Manually editing and deleting an entity - Symfony2
How do I manually edit and delete an entity in Symfony2?
I get that it creates a class, but how do I edit everything? I'm guessing I can't just change the PHP class file.
So which files does it ...
0
votes
1answer
39 views
FosUserBundle - Unique email, username and more fields
i use the FosUserBundle and i have a problem with the integrity.
Problem:
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Example' for key 'UNIQ_1483A5E94CE6C7A4'
-- ...
0
votes
1answer
32 views
FosUserBundle - Made username nullable true
Commuity,
i use the FosUserBundle and i have a problem with the username.
On my page, you only need a email and a password.
=> you could use a username! (because that, i couldnt override the ...
0
votes
1answer
22 views
How to access the entity inside the buildForm method of a form
I'm trying to get the entity inside the own form. I lazy remember a getData() method, but it doesn't exist inside the form, and I can't remember how to use it.
Is there any way to get the entity ...
0
votes
1answer
55 views
Twig and Symfony2 - Entity was not found
I have an entity that is related to some other entities.
On the end, I have an object like tat:
paper.submission.authors
For some of the paper.submission, there is no author, and in my twig ...
0
votes
1answer
16 views
Symfon2: How to set default values (options) for Entity field type?
I am creating a form which uses an Entity type.
The entity form type displays Roles as a list of checkboxes.
But I dont know how to set default values. I need to get default values from DB then ...
2
votes
1answer
46 views
Symfony2 Form Validator - Comparing old and new values before flush
I was wondering if there is a way to compare old and new values in a validator within an entity prior to a flush.
I have a Server entity which renders to a form fine. The entity has a relationship to ...
0
votes
3answers
33 views
Inserting code before assigning a form into an entity in Symfony2
Let's say that in my system there are a few user roles: ROLE_ADMIN, ROLE_MODERATOR, ROLE_CUSTOMER_PERSON, ROLE_CUSOMER_COMPANY
And in the registration form I want to let the user choose what role he ...
0
votes
1answer
31 views
Symfony Doctrine : Use real tablename in request
I'm using doctrine in a symfony project and I have a little problem.
I have a "Character" entity, and a "Equipment" entity.
The character can only wear 5 equipment on him.
But he could buy some ...
0
votes
1answer
56 views
Symfony2 entity choice issue
I have an entity form field in my Symfony2 project.
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('productId', 'genemu_jquerychosen_entity', ...
0
votes
1answer
32 views
symfony2 form entity option value
i need to create a form with symfony that has an entity type, so this is im using
->add('assignee', 'entity', array(
'label' => 'Assignee',
'class' => ...
0
votes
1answer
35 views
Entity relations without second entity (value from array)
first I appologize if the topic may confuse you. I try to explain my question. In an application there are a lot of information which are too small to build an own entity for that. Some examples ...
2
votes
1answer
53 views
Clone an entity before form bind
With Symfony2, I need to save an entity before use $form->bind() to compare the old and new one before flush.
I tried some functions :
$command = $repository->findCommandProductsByCommand( $id );
...
0
votes
1answer
47 views
How to deal with calculated entity attribute
Let's say there is an entity called Staff.
It has a number of persistent attributes, such as:
- Name
- Experience
- Age
I want to create a "virtual" attribute, that is based on the Experience and ...
0
votes
0answers
91 views
Doctrine2 Symfony2 entitymanager flush error [closed]
I have problem when i try to flush in controller.
I got this error :
Notice: Object of class
EntityManager51a8c94c43fe1_546a8d27f194334ee012bfe64f629947b07e4919__CG__\Doctrine\ORM\EntityManager
...
1
vote
1answer
33 views
Properties of an entity in a different entity
I'm using FOSUserBundle to manage the users and the security. I also have a different table that carries all the metadata of the user, like the profile picture, facebook id, etc.
I need to tell ...
0
votes
1answer
136 views
how to call function of entity repository in form type in symfony2
i want to call function in form type class. function generate array and is written in entity repository class. using that array i will generate dynamic form field.
here is entity repository class ...
1
vote
1answer
39 views
Adding custom option at form field type 'entity'
In my form builder, using an entity choice field I can retrieve the contents of an entity by:
$builder->add('manufacturer', 'entity', array(
'class' => 'Manufacturer'....
...
1
vote
2answers
179 views
Symfony2 Doctrine get random product from a category
I have the following database scheme:
table 'products'
id
category_id
and of course a category table, just with an id.
The data look something like that:
Products
--------------------
| id | ...
0
votes
1answer
28 views
Multilingual entities with inheritance?
I need some multilingual entities in our application and I want to know what are the best practice for that.
Currently it solved with an 1:n relation, because there general information and language ...
-4
votes
3answers
174 views
Symfony2 “Fatal error: Class not Found”
This is NewEventController.php:
namespace Passtuff\RestBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Response;
use ...
0
votes
0answers
262 views
Symfony2 translate form entity property
I have a symfony2 form for edit users. My users has roles and you can select multiple roles for one user.
In my form I display the UserRoles entity:
$builder->add( 'rolesAsObject', 'entity', ...
1
vote
2answers
203 views
symfony2 form multiple select with arraycollection
I would like to create a form to edit my users.
Users and roles connected with ManyToMany.
In UserUsers entity I have a $roles variable which is ArrayCollection:
public function __construct()
{
...
0
votes
1answer
32 views
Why merged entities are updated on insert?
When inserting an entity, let say article:
Article::id
Article::text
Article::author -> User
The article has an author (ManyToOne)
User::id
User::name
User::created
if I fetch the user in the ...
2
votes
1answer
107 views
Symfony2 Custom form type using entity trying to test it
I am trying to test a form type I have creating that uses a field with class entity
here is the creation of the form
$builder
->add('name', 'text')
->add('description', ...
0
votes
0answers
27 views
Entity inheritance, common methods, different implementation
Assuming that I have entities with the followin relations:
Branch->Employees (1 branch has many employees)
For example, for each employee I want to calculate the working hours. I want to subclass ...
0
votes
1answer
76 views
Symfony2 Entity Authentication doesn't work for me
I am learning how to use Authentication in Symfony2, with usernames comming from an Entity (MySQL database). I've created a simple table in PhpMyAdmin :
INSERT INTO `user` (`id`, `username`, ...
0
votes
1answer
91 views
Symfony2 flash messages from Entity Repository
Is there a way to write flash messages from entity repository. I have a Tag and Category entity.
I am adding tags via Category form, where i added a custom input field that receives tags separated ...
0
votes
1answer
136 views
Symfony2 Form “collection” + Doctrine Column “array” = Empty form_widget
I have a simple question about Symfony2's form type "collection" in combination with doctrine's column "array".**
My Entity:
/**
* @Column(type="array", nullable=true)
* @var array
*/
private ...
0
votes
2answers
193 views
symfony2 build form entity oneToMany
I am learning symfony framework and have a big problem.
I have two database table: category (primary key: categoryid) and product (primary key: productid and foreign key: category_categoryid).
In ...
0
votes
0answers
62 views
Doctrine Symfony2 create schema issue
I'm totally new to symfony2 and Doctrine.
i'm trying to create some entities which will made persistent data onto a db.
I've created my classes following Symfony's documentation.
I create the ...
1
vote
1answer
65 views
Symfony2 generate form for entity of another entity (location of a shop)
i'm trying to figure this out for a while now.
I can't find any documentation on how to do the following:
I have 2 entities Shop and Location, a shop can have more locations
The entities are already ...
0
votes
2answers
34 views
Preventing removal of entity
I have an entity (eg Image) which is related to many other entities (eg Product or Category). I would like to know which is the best way to prevent the removal of an entity if a relation exists ...
0
votes
1answer
135 views
symfony2 controller works fine in view, but does not during load:fixtures
I am struggling with the combination of a Controller, an EntityRepository, and my Doctrine Fixtures in Symfony2.
My ImageParts Entity are pieces of images. I want to randomly generate images, using ...
1
vote
0answers
83 views
Symfony: passing object to controller method
I'm following this guide in order to create a RESTFUL api:
http://williamdurand.fr/2012/08/02/rest-apis-with-symfony2-the-right-way/
In POST section, it uses object User as input of its edit method. ...
2
votes
1answer
734 views
Symfony2 - Set a selected value for the entity field
I'm trying to set a selected value inside an entity field. In accordance with many discussions I've seen about this topic, I tried to set the data option but this doesn't select any of the values by ...
1
vote
1answer
57 views
Set form DateTime data2 to form data1 + 1 day
I had had a problem to set a Form Field DateTime (named endDate) to the Form Field DateTime (named startDate + 24h) if no data for endDate is typed into the form)
The solution (thanks to the ...
2
votes
1answer
76 views
What is entity manager in symfony 2 and how it works internally?
Can anybody please help me to understand the concept of entity manager, what it is, how it works and why we need it ?
0
votes
2answers
186 views
Symfony Roles as Entities Form issue
I have a custom handler for roles like as entity and many to many relationship like so:
<?php
namespace Digital\UserBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use ...
2
votes
1answer
165 views
Symfony 2.2, Doctrine 2: Complex relational entity retrieval
Background
I'm working on a portfolio website, the website is fairly simple, the bulk of the work is on the gallery. I have a a set of database tables all linked up to retrieve and filter galleries ...
1
vote
1answer
55 views
Symfony2 extensible collection entities from different bundles
I am building a CMS that has an abstract definition of an asset.
A page is a collection of assets.
The collection would store details of what is in the collection - but the entities are responsible ...
1
vote
1answer
67 views
show many to many relationship field label in symfony2
I have an entity News bound to an entity Company with a many to many relationship.
Such relationship is set in a form through an entity field where I can select companies tied to my news.
Everything ...
1
vote
2answers
211 views
Symfony2 merge multi step form to one result
These are my first steps on SF2. I want to set up a multi step form on an entity which contains other entities.
I've a form type (shortened)
class ApplicationFormType extends AbstractType
{
...
0
votes
1answer
186 views
symfony2 entity oneToMany and methods
Hi i had fully successfully setted my entity onetoMany and ManyToOne i generated setters and getters and in user entity it created this method:
user entity:
/**
* ...