public function Field($properties = array()) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js'); Requirements::javascript(DYNAMICLIST_MODULE . '/javascript/DependentDynamicListDropdownField.js'); $listItems = array(); if (is_string($this->dependentLists)) { $list = DynamicList::get_dynamic_list($this->dependentLists); if ($list) { $this->dependentLists = $list->Items()->map('Title', 'Title')->toArray(); } } if (!is_array($this->dependentLists)) { $this->dependentLists = array(); } foreach ($this->dependentLists as $k => $v) { $list = DynamicList::get_dynamic_list($k); if ($list) { $listItems[$k] = $list->Items()->map('Title', 'Title')->toArray(); } } $this->setAttribute('data-listoptions', Convert::raw2json($listItems)); $this->setAttribute('data-dependentOn', $this->dependentOn); if ($this->value) { $this->setAttribute('data-initialvalue', $this->value); } return parent::Field(); }
function getFormField() { return DynamicListField::create($this->Name, $this->Title, $this->ListTitle); }