Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo

has_one without a table?


Go to End


3 Posts   1143 Views

Avatar
UncleCheese

Forum Moderator, 4102 Posts

5 September 2008 at 8:19am

An event has_one DateTime. How can I update the DateTime DataObject associated with the event with just textfields?

static $has_one = array (
'DateTime' => 'DateTime'
);

// getCMSFields
...

new TextField('DateTime.StartDate', 'Start Date');
new TextField('DateTime.StartTime', 'Start Time');

... doesn't work. Any way to to this?

Avatar
Willr

Forum Moderator, 5523 Posts

5 September 2008 at 3:57pm

Do you need to use has_one? cant you just have 2 fields on the database "StartDate" and "StartTime"

Avatar
UncleCheese

Forum Moderator, 4102 Posts

6 September 2008 at 1:29am

Yeah, that's the thing. The dataobject DateTime is shared across two modules. The other module can add to it in with a has_many relationship, but this module has a has_one. On the frontend I just want to be able to get all of them regardless of where they came from.