Hello.
From the TreeDropdownField API, it's my understanding that the $keyField is the column in the $sourceObject where the data that will be stored will come from. If I do the following:
class HomePage extends Page
{
function getCMSFields()
{
$fields = parent::getCMSFields();
$fields->addFieldToTab('Root.Content.Buttons', new TreeDropdownField('LinkID', 'Choose a page to Link to:', 'SiteTree', 'URLSegment'));
return $fields;
}
}
I would expect that in my table (HomePage), the "LinkID" column will be a varchar that stores the URLSegment. However, when I do a dev/build, the follwoing is created:
Field HomePage.LinkID: created as int(11) not null default '0'
It appears that the build ignores the $keyValue and sticks with the default of "ID". While the form functionality is as expected, when I save, I only get the default 0 in the row (as I would expect based on how the table was created).
I feel like I may be missing a something, I've tried something like this:
class HomePage extends Page
{
static $db = array(
'LinkID' => 'Text'
);
.
.
.
but that just gets ignored.
Any ideas as to what I'm doing wrong?
Cheers.