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 works fine except that company ids are showed as labels.
Is there a way to force another and more meaningful table field is showed as a label?
Have look at entity form field type reference. Specifically property option.
http://symfony.com/doc/current/reference/forms/types/entity.html#property
Related
Is it possible to reference additional columns apart from the 'Code' and 'Name' columns when using a domain attribute in an entity?
E.g. A person entity has a code of '1' and a name of 'Smith' and a Gender of 'Male'
In a customer entity there is a domain value referencing the person entity which displays the following 1 {Smith}. The users would like an additional read only attribute which would copy the Gender value of 'Male' into the customer entity based on the domain value. Can this be done using out of the box MDS UI?
I know this is duplicate data and breaks normal form but for usability this would be useful. It would be the equivalent of referencing additional columns in an MS Access drop down list.
Many thanks in advance for any help
This is not possible with the standard UI. One option would be to develop a custom UI where you can handle these kind of requests.
If you want to stick with the standard product I can see a workaround but this is a bit of a "dirty" one.
You can misuse (abuse) the Name attribute of the Person entity by adding a business rule to the Person entity that generates the content of the Name attribute as a concatenation of multiple attributes. You of course need an additional attribute that serves as a place holder for the original Name. The concatenated field will then show in your customer entity.
One question that does come to mind is why a user would like/need to see the gender of a person in a customer list? As you have a separate Person entity I expect you to have multiple persons per customers. What would the gender of one person - even if it is the main contact - matter?
The objective:
Having a many-to-many relation be displayed as a dynamic list of select inputs(single choice dropdown list)
User arrives on page with a single select field (multiple = false) populated with persisted entities and add/remove buttons. By clicking the add button, a new select field with the same options appears below the first, which adds a new entry in the M2M relation. By clicking remove the field disappears and the entry should be removed.
The model:
Two entities: User & Manager. A User has exactly one "special" Manager and unlimited normal Managers.
Managers manage unlimited users.To model this I have created two relationships for which the user is the "owner" (not sure how to translate this)
ManyToOne specialManager
ManyToMany normalManagers
I haven't created a many to many relationship with attribute "special" because the requirement is exactly one special manager and I wasn't sure if Symfony/Doctrine would cause problems down the line.
What I have:
I can display a multiple select field with the existing entities using Entity field type, as per the documentation. Functionally this is what I need, visually it is not.
I can also use the Collection field type to display a single text field, and add or remove more with JS, as per the documentation. Visually this is what I need, but The text fields (entity attribute) need to be replaced by choice field.
The question:
Before I continue digging, is there a simple way to achieve this list of select tags?
For anyone else who may eventually need a dynamic list of select fields:
I initially solved this issue by detaching the field(s) in event listeners, and handling the display/submission manually in the controller.
However I wasn't satisfied with this clunky solution and when I encountered the same need I used a second solution: creating an intermediary entity xxxChoice (in this case ManagerChoice) which is Mto1 inversed related to User and Mto1 related to Manager. Then by creating a ManagerChoiceType form with "Manager" entity field type I was able to easily display my collection of dropdown select lists.
I have two entities called 'Member' and 'Role'. At the same page as I show the data of the 'Member' entity I would like to add a form for adding roles (one 'Role' per request) to this 'Member'.
Adding a new 'Role' entity includes the information of the related 'Member'. So the form must include a 'Member' entity to that handleRequest($request) works properly. What is the easiest way to hide this 'Member' entity in the form?
I have already googled a bit, but without satisfactorily results. I turned out following approaches:
using the symfony-generate-crud-default-settings: and
and hide them with css
using a hidden textfield with the ID
of the member Data Transformers to transform the hidden textfield
with a number back into a 'Member' entity
Option 1) looks more like a hack, while option 2) needs a lot of code for just a simple task. Is there no possibility to put the whole Member entity into a form component so that handleRequest($request) can handle the related entities properly?
If I understood you right, Member and Role entities has ManyToMany association. In this case you should use 'collection' form type.
I am using Breeze (http://www.breezejs.com/) and to use the functionality I want it requires mapping to a complete entity and all of its fields. I have a "Person" entity, but it includes a Social Security Number field. I want to keep this SSN# field private so I would like to create an entity named SubSetPerson that is updateable, has navigation properties and only contains the columns I want (e.g. ID, FirstName, LastName, myNavigationProperty) and does not contain the SSN#. I am using database/model first. Is this possible?
If you are using database first, then you could create a view for that table which only selects the columns you want. Then update the EF model browser to include that view.
Try using a Master-Detail type structure for your person. The master table would contain the person's public information; ie name, birthdate, etc... The detail table would contain only the more sensitive information (SSN, etc...). Then depending on your needs you can load the detail or not.
I was noticing that the designer for the edmx is giving the entities and classes strange names, all in plural etc, what should be the correct naming for it?
like it is now is like:
Customers (entity)
CustomersSet (setname)
Cusomters (navigation property)
shall it be:
Customer (entity)
Customers (setname)
Customer (navigation property)
?
TIA
/M
If the designer is giving your entities plural names, that means that your database has plural table names. That's fine. Entity Framework version 4 will pluralize things automatically, but for now you need to fix this up yourself.
What I do is:
Entity type names are always singular
Entity set names are always plural
Navigation property names are either singular or plural, depending upon the cardinality of the relationship. So a one to one property would be singular, and a one to many property would be plural.
I would tend to agree on the two first present in the list. the last one may be a set or a single entity.
Customer (entity) Customers (setname) Customer (navigation property)