Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Custom EntityType to display two properties of an entity in list
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Matt Durak  
View profile  
 More options Oct 19 2012, 2:29 am
From: Matt Durak <mattsnowbo...@gmail.com>
Date: Thu, 18 Oct 2012 23:29:09 -0700 (PDT)
Local: Fri, Oct 19 2012 2:29 am
Subject: Custom EntityType to display two properties of an entity in list

I want to use the EntityType to display a list of entities and allow the
user to select one.

        $builder->add('icon', 'entity', array(
            'class' => 'MyMainBundle:MenuIcon',
            'property' => 'name',
            'expanded' => true,
            'multiple' => false
        ));

However, I want the output to be something like this:

    <label class="radio"><input type="radio" id="..." name="..." required="
required" class="" value="1" /><img src="MY IMAGE" alt="" />MY NAME</label>

For each entity item. (MY IMAGE and MY NAME come from properties of the
entity)
So the default EntityType can handle this except for the <img...> tag.

I want to know how to extend the EntityType to still enumerate over all
entities of a given class but to expose TWO properties (or more) so that
the theme can display it as above. I haven't been able to figure it out
since the implementation for EntityType is a bit more complex than other
form Types. But I am aware of the cookbook entry on creating a new type.

Anyone know if this is possible? Should I just give up on Symfony forms and
write the code myself?
(This is Symfony 2.1.x)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
loostro  
View profile  
 More options Nov 5 2012, 4:21 pm
From: loostro <loos...@gmail.com>
Date: Mon, 5 Nov 2012 13:21:00 -0800 (PST)
Subject: Re: Custom EntityType to display two properties of an entity in list

Simply override form widget. You have access to the entity object in there
and instead of displaying just it's name you may use any other entitie's
property in there.

W dniu piątek, 19 października 2012 08:29:10 UTC+2 użytkownik Matt Durak
napisał:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »