is there already a way to populate eForm dynamically?
I like to use ditto to populate a dropdownlist with event dates my template looks like this:
Dimmy, Yes there is and there are several examples in the forums, but you can not use snippet tags inside eform chunks for the simple reason that they are evaluated after eForm has finished executing! As eForm uses the data parsed from the form chunk to validate select fields (and check and radio boxes) dynamically filling these fields needs to happen BEFORE eform parses the form.
So in your case you need to use the eFormOnBeforeParseFOrm event and execute your ditto call there using $modx->runsnippet()
<?php
function BeforeFormParseFunction(&$fields, &$templates){
global $modx;
$ditto_params => array(
'startID' => '24',
'tpl' => 'agendaform_tpl',
'multiLevel' => '1'
'filter' => 'vol,yes,7',
'language' => 'nederlands',
'total' => '99',
'sortBy' => 'unpub_date',
'dateFormat' => '%d %B %Y',
'sortDir' => 'ASC' ,
'summarize' => '99'
);
$templates['tpl'] = str_replace('[+ditto_placeholder+]',$modx->runsnippet('Ditto',$ditto_params),$templates['tpl']);
return true;
}
?>
Your template chunk would then contain this:
<select class="formselect" name="thisshowdate" eform="For this show::0"/>
<option value=''> </option> <!-- In case you want to leave option of not selecting anything -->
[+ditto_placeholder+]
</select>
and you add &eFormOnBeforeParse=`BeforeFormParseFunction` to your eForm snippet call.