enable Selected option for a custom field extending JFormFieldList

I am creating a custom field extending JFormFieldList as below class JFormFieldRelationTypeList extends JFormFieldList{ protected $type = ‘mycustomfield’; public function getOptions($id=”) { $options = array(); $default_values = array(1,2); $this->_db = JFactory::getDBO(); $query = $this->_db->getQuery(true); $query->select($this->_db->quoteName(‘key’)); $query->select($this->_db->quoteName(‘value’)); $query->from($this->_db->quoteName(‘#__jsch_custom_table’)); $this->_db->setQuery($query); try{ $objlist = $this->_db->loadObjectList(); } catch (RuntimeException $e) { } foreach($objlist as $obj) { $tmp = new…