I have a Text field called selecetdIndividuals on Page Table. eg: 18,19,20
I want to use it to show the chosen Individuals which are in my Individuals table.
in my Page.php if manually set the values it works.
if try and make it dynamic its doesn't,, but i have echoed $selectedIndividuals and they display.
public function SelectedStaff($selectedIndividuals) {
if ($selectedIndividuals) {
// comment out $idList = new Array($selectedIndividuals);
//manually set
$idList = array(18,19,20);
$dl = DataList::create('Individual')->byIDs($idList);
return $dl;
} else {
echo "non some values are null like this one";
}
}
so what i mean is when i do $idList = $selectedIndividuals; i get an error
[Warning] array_map(): Argument #2 should be an array
Line 781 in /home/hmyapp/public_html/framework/model/DataList.php
773
774 /**
775 * Filter this list to only contain the given Primary IDs
776 *
777 * @param array $ids Array of integers, will be automatically cast/escaped.
778 * @return DataList
779 */
780 public function byIDs(array $ids) {
781 $ids = array_map('intval', $ids); // sanitize
782 $baseClass = ClassInfo::baseDataClass($this->dataClass);
783 $this->where("\"$baseClass\".\"ID\" IN (" . implode(',', $ids) .")");
784
785 return $this;
786 }