I need to fulfill a field in a entity by displaying dropdown select fields. By choosing an option on a first select, It must display a second select with options relative to this first choice. An so on for one or two select more.
Do you have any ways or useful documentation to accomplish that?
Sadly, that's not really what I need. The ShtumiUsefulBundle and dependent_filtered_entity works with fields depending of two different entities. I need to work with one field on a unique entity.
To be more descriptive, I've got a field in an entity which is a foreign key to another entity. This another entity as code beginning as A,B, etc. But goes further like A1,A2, etc.
What I need is to display the first level choice in a select, and after this choice has been made, to display a second select with relatives further choices. I hope I have succeed to explain it in a comprehensible way.
Thanks
Le mardi 28 août 2012 10:48:30 UTC+2, Julien Duthoit a écrit :
> Sadly, that's not really what I need. The ShtumiUsefulBundle and > dependent_filtered_entity works with fields depending of two different > entities. > I need to work with one field on a unique entity.
> To be more descriptive, I've got a field in an entity which is a foreign > key to another entity. > This another entity as code beginning as A,B, etc. But goes further like > A1,A2, etc.
> What I need is to display the first level choice in a select, and after > this choice has been made, to display a second select with relatives > further choices. > I hope I have succeed to explain it in a comprehensible way.
> Thanks
> Le mardi 28 août 2012 10:48:30 UTC+2, Julien Duthoit a écrit :
>> If there is a bundle for that, it's perfect. >> I'll check that and keep this thread posted.
>> Thanks
>> Le mardi 28 août 2012 10:43:50 UTC+2, wayne a écrit :
>>> Hi,
>>> > Do you have any ways or useful documentation to accomplish that?
>>> Try the ShtumiUsefulBundle and dependent_filtered_entity :)
I didn't know this Doctrine feature, maybe it can work with that. It doesn't work with my entity structure for the moment so I'll have to modify it before.
Thanks!
Le mardi 28 août 2012 12:38:59 UTC+2, leonardo a écrit :
> Il giorno martedì 28 agosto 2012 11:28:47 UTC+2, Julien Duthoit ha scritto:
>> Sadly, that's not really what I need. The ShtumiUsefulBundle and >> dependent_filtered_entity works with fields depending of two different >> entities. >> I need to work with one field on a unique entity.
>> To be more descriptive, I've got a field in an entity which is a foreign >> key to another entity. >> This another entity as code beginning as A,B, etc. But goes further like >> A1,A2, etc.
>> What I need is to display the first level choice in a select, and after >> this choice has been made, to display a second select with relatives >> further choices. >> I hope I have succeed to explain it in a comprehensible way.
>> Thanks
>> Le mardi 28 août 2012 10:48:30 UTC+2, Julien Duthoit a écrit :
>>> If there is a bundle for that, it's perfect. >>> I'll check that and keep this thread posted.
>>> Thanks
>>> Le mardi 28 août 2012 10:43:50 UTC+2, wayne a écrit :
>>>> Hi,
>>>> > Do you have any ways or useful documentation to accomplish that?
>>>> Try the ShtumiUsefulBundle and dependent_filtered_entity :)
I've tried with your advice of a self-referenced entity, but it seems not to work like that. Maybe I'm wrong?
I join you my base table (I hope it's enough readable) and my entity definition : http://pastebin.com/5GYvhB5p
Maybe someone will see what's wrong. Thanks for your help
Le mardi 28 août 2012 16:22:41 UTC+2, Julien Duthoit a écrit :
> I didn't know this Doctrine feature, maybe it can work with that. It > doesn't work with my entity structure for the moment so I'll have to modify > it before.
> Thanks!
> Le mardi 28 août 2012 12:38:59 UTC+2, leonardo a écrit :
>> I'm not sure that I understand the question and I never used >> ShtumiUsefulBundle but reading the documentation:
>> parent_property - property that contains master entity with ManyToOne >> relationship
>> So I think you can use a "One-To-Many, Self-referencing"
>> Il giorno martedì 28 agosto 2012 11:28:47 UTC+2, Julien Duthoit ha >> scritto:
>>> Sadly, that's not really what I need. The ShtumiUsefulBundle and >>> dependent_filtered_entity works with fields depending of two different >>> entities. >>> I need to work with one field on a unique entity.
>>> To be more descriptive, I've got a field in an entity which is a foreign >>> key to another entity. >>> This another entity as code beginning as A,B, etc. But goes further like >>> A1,A2, etc.
>>> What I need is to display the first level choice in a select, and after >>> this choice has been made, to display a second select with relatives >>> further choices. >>> I hope I have succeed to explain it in a comprehensible way.
>>> Thanks
>>> Le mardi 28 août 2012 10:48:30 UTC+2, Julien Duthoit a écrit :
>>>> If there is a bundle for that, it's perfect. >>>> I'll check that and keep this thread posted.
>>>> Thanks
>>>> Le mardi 28 août 2012 10:43:50 UTC+2, wayne a écrit :
>>>>> Hi,
>>>>> > Do you have any ways or useful documentation to accomplish that?
>>>>> Try the ShtumiUsefulBundle and dependent_filtered_entity :)
Hello! For AJAX purposes i use the YUI from Yahoo. However. Why don't you call an url after an onselect event like http://my.com/getsecondList?choice1=A that returns JSON or XML and fill your second choice list with this result?
*you need an entry in your routing.yml like * _getsecondList: pattern: /getSecondList/{firstChoice} defaults: { _controller: ExampleBundle:Default:getSecondList} *you need a controller (DefaultController for example):* class DefaultController extends Controller { public function getSecondListAction($firstChoice) { if ($firstChoice== blala){ $secondChoice= get second choice content
*a twig-xml file like e.g. secondChoice.xml.twig* <?xml version="1.0"?> {% for c in secondChoice %} <Choice> <item>{{ c }}</item> </Choice> {% endfor %}
Thanks for your advices. With this solution, it's no more less than a Javascript problem now... Sadly, I'm not very good with it for the moment but it's a reason to learn more.
Le mardi 28 août 2012 10:41:28 UTC+2, Julien Duthoit a écrit :
> I need to fulfill a field in a entity by displaying dropdown select > fields. > By choosing an option on a first select, It must display a second select > with options relative to this first choice. An so on for one or two select > more.
> Do you have any ways or useful documentation to accomplish that?