Hi,
I am not convinced this question belongs to this section (even though it is happening in a Popup Window) ..so please feel free
to reroute ...
I am using a very simple example to illustrate my question.
On one side, I have an DataObject :
class NavigationCountry extends DataObject {
static $db = array(
'CountryName' => 'Text',
);
This object is populated with DOM - No problem.
On the other side I have another DataObject
class NavigationEntry extends DataObject {
static $db = array(
'Country' => 'Text',
'Description' => 'HTMLText'
'HighlightFlag' => "Enum('Yes,No','No')"
);
$fields = new FieldSet( new DropdownField(
'Country',
'Please choose a country',
Dataobject::get("NavigationCountry")->toDropdownMap("CountryName", "CountryName")
),
new DropdownField(
'HighlightFlag',
'Highlight Flag',
singleton('NavigationEntry')->dbObject('HighlightFlag')->enumValues()
),
new SimpleTinyMCEField('Description', 'Description')
);
As you can see , the "Country" field of NavigationEntry is a DropDownField populated by a DataObject::get() on the other
object Country followed by a toDropdownMap().
The object NavigationEntry is managed in the page template by an DataObjectManager ....and it works fine
EXCEPTED that everytime an entry is updated , the DropDownField 'Country' is displayed with the first option selected
NOT the data stored for this entry.
What is strange is that it works correctly for the other DropdownField (HighLightFlag) which is generated with an Enum . I mean
that if I create en entry with "Yes" and edit it, the dropdownList will be set correctly to "Yes" .
Why do the two DropDownField work differently? If there a way to have the "Country" list mark as "selected" the value/index
already stored fro this entry instead of selecting the first value by default?
Hope this is not too confusing.
Any help or advice appreciated .
Thanks - Lise