Share » Forums » Developer » DataType: Matrix with fixed values

DataType: Matrix with fixed values

DataType: Matrix with fixed values

Thursday 24 July 2008 1:50:58 am - 4 replies

Author Message

Robert Ledoux

Monday 04 August 2008 10:05:30 am

Hello

have you find a soution for this problem :
http://ez.no/developer/forum/developer/datatype_matrix_with_fixed_values

thanks for your answer.

chap

Gabriel Finkelstein

Monday 04 August 2008 4:07:22 pm

You could make 2 classes: Region and City. Each City has an object relation with a Region. You store regions and cities in 2 different folders. And in the edit template of your class, you add an objectrelation for region and another for city.
Both relation input fields should be dropdowns. The "Region" dropdown:

<select name="region" onchange="changeCities(this.options[this.selectedIndex].value)">
{foreach $regions as $region}
   <option value={$region.id}>{$region.name}</option>
{/foreach}
</select>

The "City" dropdown:

<select name="city">
{foreach $cities as $city}
   <option value={$city.id} region={$city.data_map.region.content.id}>{$city.name}</option>
{/foreach}
</select>

Or something like that. And then make a javascript function called changeCities(), which hides the cities from the dropdown, that don't belong to the selected region.

Of course, there's no kind of validation, so a user could actually pick a region and a city that doesn't belong to that region.

Maybe there's some kind of "Related Dropdowns" datatype somewhere.

Albe Terra

Tuesday 05 August 2008 7:04:32 am

Thanks a lot!
I will try with this solution!

If other solutions come to your mind, please tell me :)

Thanks again for your help,
Albe!

Piotrek Karaƛ

Tuesday 05 August 2008 11:49:40 am

With little effort, you can make a custom datatype operate on any custom data model (db table set), so if you do not need the regions/cities to be objects, you could backup Gabriel's idea with some lightweight 1:n db tables, and even provide UI for managing those tables in the administration interface. That would then work as one coherent attribute of a class.

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu