0

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 gender or status.

Is there a recommended way to do that or is it still an entity with two to five value in a table?

What I need is the standard behaviour in forms (selectbox) and show the value by an id.

3
  • But the gender in this case is related with something right? Can you put a example ? Commented Jun 7, 2013 at 10:58
  • Imaging you have an entity 'Person' and you want configure it as male or female. Just a little dropdown. But I don't want to create an entity with a table for that two values. Sure I could config the form as well, but then I got only the ID from my Person entity and not the string male or female. You know what I mean?
    – Daniel
    Commented Jun 7, 2013 at 11:05
  • ok, but assing to the entity person for example column gender with values 0 and 1, for male or female. According with this value set after that the combobox. Is the more logic. Commented Jun 11, 2013 at 8:02

1 Answer 1

1

I would certainly create these as entities!

You may feel it to be overkill, especially when you are just populating select boxes. However, it will be required to create the correct entity relationships such as $user->getGender()->getName() etc I doubt that the Gender options will change but it will be a reusable class for all your other projects.

Remember that Doctrine and other popular ORMs will proxy access to the object so it will be called in a lazy manner.

You could also use a "view helper" of some description that directly queries the database for the values you want and displays the select options accordingly, while you are still using your new entities elsewhere.

1
  • Ok, if this is the common way I'll use it. I just thought it could be easier. Thank you guys!
    – Daniel
    Commented Jun 7, 2013 at 11:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.