Am 06.12.17 um 11:34 schrieb Peter Uhnák:
Hi,
I'm trying to get dependent magritte descriptions, but it seems like this is not something that can be done in the descriptions:
Imagine a class Contact with "city" and "country" descriptions. I would like to populate the city description based on the currently selected country
~~~~~~~~~~~~~~~~~~~~~~ descriptionCountry <magritteDescription> ^ MASingleOptionDescription new accessor: #country; label: 'Country'; options: self countries; yourself
descriptionCity <magritteDescription> ^ MASingleOptionDescription new accessor: #city; label: 'City'; options: (self citiesInCountry: self country); yourself ~~~~~~~~~~~~~~~~~~~~~~
The problem with this approach is that both descriptions are in the same form, so I need to update the cities list even before the country is saved back into the object.
Is this possible in magritte?
I had the same wish and came up with the following solution: --- It will calculate the options with a block instead of an already given collection. --- It will recalculate (aka "not cache") the options if you hit the "Save" button on the magritte form. --- It will NOT recalculate the options on the fly when the other dropdown box has been selected. This probably could be done with some ajax stuff or a forced HTTP form send. --- I use my own subclasses for magritte options, for example: MASingleOptionDescription subclass: #ALMaSingleModelOptionDescription uses: TALMagritteOptionDescription instanceVariableNames: '' classVariableNames: '' package: 'Albus-Magritte' --- See attached fileout of the Trait TALMagritteOptionDescription. --- You can then describe an option as follows: descriptionYourAttribute <magritteDescription> ^ALMaSingleModelOptionDescription new accessor: #yourAccessor; optionsBlock: ["stuff to calculate your collection"]; label: 'Your label'; yourself Cheers, Andreas -- Andreas Brodbeck www.mindclue.ch