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.

Archive /

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

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

There has to be a way...


Reply


3 Posts   888 Views

Avatar
UncleCheese

Forum Moderator, 4096 Posts

11 July 2008 at 8:01am

I have a CurriculumDate object on a ComplexTable field. One of its components is a has_many with KeynoteSpeakers. Users choose any number of keynote speakers from checkboxes in the popup, and it works great.

But on the table, I'd like the list of selected keynote speakers to display in a comma-separated list. I tried $table->setFieldFormatting(array('KeynoteSpeakers' => '$MyCommaFunction')), but it looks like that isn't designed to take functions as variables. When I did $ID, it did give the id of the CurriculumDate, however.

I've tried a number of things. My latest hack is to use fieldCasting to cast the KeynoteSpeakers as Enum, and i've hacked the Enum fieldtype to include a function "toCSVList" that looks like this:

   function toCSVList()
   {
      return implode(', ', $this->enumValues(false));
   }

not so hot, though, and barely works.

Anything?

Avatar
Sam

Administrator, 685 Posts

14 July 2008 at 5:31pm

On the object that has the KeynoteSpeakers, create a methiod called getKeynoteSpeakersList

function getKeynoteSpeakersList() {
foreach($this->KeynoteSpeakers() as $item) // etc
return $something;
}

This will create a dynamic property - $obj->KeynoteSpeakersList

Which means that you can add KeynoteSpeakersList as a column to your CTF.

Avatar
UncleCheese

Forum Moderator, 4096 Posts

16 July 2008 at 2:28am

Worked first try. I knew there had to be a way! Thanks, Sam!!