Dynamic select options in form

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Dynamic select options in form

g.fitini
Hi to every one, i want toknow if it’s possible to do something like that.

For Example, i’ve a a field like :


<field name="idState" title="state" field-name="state"
          <drop-down allow-empty="true" current-description="">
              <entity-options description="${idState}" key-field-name="idState" entity-name="TableStates">
                  <entity-order-by field-name="idState"/>
              </entity-options>
          </drop-down>
      </field>

So, i can do a choice, between : {U.S.A., Europe, ...etc}

Now in the same form, i want another dinamic field where, i can choose just the Country associated to the field named ‘idState’.


<field name="idCountry" title="Country" field-name="Country"
          <drop-down allow-empty="true" current-description="">
              <entity-options description="${idCountry}" key-field-name="idState" entity-name="TableCountry">
                  <entity-order-by field-name="idCountry"/>
              </entity-options>
          </drop-down>
      </field>

So, if i’ve choice  ‘Europe’  in the field ‘idState’, i want that appear in the field ‘idCountry’ a select with : {Italy, Spain, Greece,...etc}

States, and Countries, are in two differents tables. And the countries has a reference to States table.


Thanks in advance.




Reply | Threaded
Open this post in threaded view
|

Re: Dynamic select options in form

Jacques Le Roux
Administrator
https://demo-trunk.ofbiz.apache.org/example/control/FormWidgetExamples#DropDownFieldsExampleForm_dependendDropDownFields_title

Jacques

Le 03/03/2014 15:02, [hidden email] a écrit :

> Hi to every one, i want toknow if it’s possible to do something like that.
>
> For Example, i’ve a a field like :
>
>
> <field name="idState" title="state" field-name="state"
>            <drop-down allow-empty="true" current-description="">
>                <entity-options description="${idState}" key-field-name="idState" entity-name="TableStates">
>                    <entity-order-by field-name="idState"/>
>                </entity-options>
>            </drop-down>
>        </field>
>
> So, i can do a choice, between : {U.S.A., Europe, ...etc}
>
> Now in the same form, i want another dinamic field where, i can choose just the Country associated to the field named ‘idState’.
>
>
> <field name="idCountry" title="Country" field-name="Country"
>            <drop-down allow-empty="true" current-description="">
>                <entity-options description="${idCountry}" key-field-name="idState" entity-name="TableCountry">
>                    <entity-order-by field-name="idCountry"/>
>                </entity-options>
>            </drop-down>
>        </field>
>
> So, if i’ve choice  ‘Europe’  in the field ‘idState’, i want that appear in the field ‘idCountry’ a select with : {Italy, Spain, Greece,...etc}
>
> States, and Countries, are in two differents tables. And the countries has a reference to States table.
>
>
> Thanks in advance.
>
>
>
>
>