現狀: 足球賽鬆過程中遇到的事件的列表。如果我從列表中選擇Saison,我會得到另一個包含所有分配給該Saison的事件的列表。 活動的賽鬆在列表被稱爲:
com_mycomponent /圖= eventlists & saisonid = 2011
這將顯示我分配到SAISON現在2011
我」的所有事件的列表倒要創建SAISON一個新的事件2011年
Add按鈕將調用:eventlist.add
MyComponentControllerEventList extends JControllerForm
在添加操作期間,我想將saison(2011)以某種方式傳遞給表單。
模型包含:
public function getTable($type = 'EventList', $prefix = 'MyComponentTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_mycomponent.eventlist', 'eventlist', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_mycomponent.edit.eventlist.data', array());
if (empty($data)){
// generate an empty item
$data = $this->getItem();
}
return $data;
}
因此,它是直線前進。
該視圖也是一種默認設置。
public function display($tpl = null)
{
// get the Data
$form = $this->get('Form');
$item = $this->get('Item');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode('<br />', $errors));
return false;
}
// Assign the Data
$this->form = $form;
$this->item = $item;
// Display the template
parent::display($tpl);
}
有沒有想過這個? 感謝
你不能在形式直接傳遞價值?你在使用JTable嗎?更多的信息/你的組件的代碼將是必要的,以瞭解你在做什麼。 –