I'm working on custom Joomla MVC component for Joomla 2.x. I have a .xml file for custom menu item type. I need to get the value_field from it to tell the view what to show from database. I tried and researched everything and it seems nothing works for me.
Here's the codes:
default.xml
<?xml version="1.0" encoding="utf-8"?>
<metadata>
<layout title="League select">
<message>Selector for league view on site</message>
</layout>
<fields name="request">
<fieldset name="request">
<field name="selLeag"
type="sql"
label="Select league"
query="SELECT leagueName, id FROM footleague_leagues"
key_field="id"
value_field="leagueName"
required="true"
>
<option value="">Select league</option>
</field>
<field name="selDiv"
type="sql"
label="Select division"
query="SELECT divisionName, id FROM footleague_divisions"
key_field="id"
value_field="divisionName"
required="true"
>
<option value="">Select division</option>
</field>
</fieldset>
</fields>
leagueinfo.php model
<?php
defined('_JEXEC') or die('Restricted access');
jimport('joomla.application.component.modelitem');
class FutLigaModelLeagueInfo extends JModelItem{
protected $msg;
public function getMsg(){
if(!isset($this->msg)){
//this shows me only the ids from database but I need value_field
$leagueid = JRequest::getVar('selLeag');
$divisionid = JRequest::getVar('selDiv');
//this shows me an empty array
$data = JFactory::getApplication()->input->get('jform', array(), 'array');
echo $leagueid;
echo $divisionid;
print_r($data);
}
return $this->msg;
}
}
?>
Thank you for help! :)