Ich hab in der Kindtable eine "option_callback" in mein PID eingebaut:
PHP-Code:
'pid' => array
(
'label' => &$GLOBALS['TL_LANG']['tl_market_course']['pid'],
'inputType' => 'select',
'exclude' => true,
'flag' => 1,
'foreignKey' => 'tl_market_price.title',
'options_callback' => array('tl_market_course', 'sorting_title_callback'),
'eval' => array('includeBlankOption'=>true, 'submitOnChange'=>true, 'mandatory'=>true, 'findInSet'=>true, 'tl_class'=>'w50'),
'sql' => "int(10) unsigned NOT NULL",
'relation' => array('type'=>'belongsTo', 'load'=>'lazy')
),
Weiters hab ich dann in meiner Class folgendes eingebaut:
PHP-Code:
public function sorting_title_callback()
{
$options = Array();
$result = $this->Database->prepare("SELECT id, title, sorting FROM tl_market_price ORDER BY sorting ASC")
->execute();
while ($result && $result->next() )
{
$options[$result->id] = $result->title;
}
return $options;
}
Das war's auch schon.
Lesezeichen