SS3.0.2
I'm trying to replicate the comma separated field for the Tags in BlogEntry.php. I'm pretty close, but not very familiar with PHP. I'm doing this since widgets can't use a Gridfield.
I have 2 textfields in a widget where both accept comma separated data. (I have it working with just the one field, but not sure how to get the second field into the same Array or if I should do two foreach loops and combine them somehow.
class VideoWidget extends Widget {
static $db = array(
'VideoTitle' => 'Varchar(150)',
'VideoLink' => 'Text'
);
public function getVideos() {
$videos = preg_split(" *, *", trim($this->VideoLink));
$titles = preg_split(" *, *", trim($this->VideoTitle)); // how do I get this second field into the array?
$output = new ArrayList();
foreach($videos as $video) {
$output->push(new ArrayData(array(
'VideoLink' => $video,
'VideoTitle' => $title
)));
}
if($this->VideoLink) {
return $output;
}
}
}
Thank you