<![CDATA[ foreach single placeholder - MODX Community Forums]]> https://forums.modx.com/thread/?thread=103306 <![CDATA[foreach single placeholder]]> https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555926
i try to get my pagetitles as single option-values (placeholder) like this:

<form method="POST" class="form" action="[[~[[*id]]]]">
<select>

    <option>Sport</option>

    <option>Cars</option>

</select>
<input type="submit" value="Send" /></form>


but my snippet put all pagetitle in one row like this:

<form method="POST" class="form" action="[[~[[*id]]]]">
<select>

    <option>SportCars</option>

</select>
<input type="submit" value="Send" /></form>


What ist wrong here? Please help.



My Snippet:

$collection = $modx->getCollection('modResource',array('template' => 4));
 
foreach ($collection as $collect){
    $mytitle.=$collect->get('pagetitle');
    $list = "<option>". $mytitle. "</option>";
    $modx->setPlaceholder('list',$list);
}

return;


HTML Form:

<form method="POST" class="form" action="[[~[[*id]]]]">
<select>
[[+list]]
</select>
<input type="submit" value="Send" /></form>
]]>
joe-petts Dec 16, 2017, 10:46 PM https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555926
<![CDATA[Re: foreach single placeholder]]> https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555929 joe-petts Dec 17, 2017, 09:39 AM https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555929 <![CDATA[Re: foreach single placeholder (Best Answer)]]> https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555927
$collection = $modx->getCollection('modResource',array('template' => 4));
$list = '';  
foreach ($collection as $collect){
    $mytitle = $collect->get('pagetitle');
    $list .= "<option>". $mytitle. "</option>";
}
$modx->setPlaceholder('list',$list); 
return;
]]>
Bruno17 Dec 17, 2017, 06:20 AM https://forums.modx.com/thread/103306/foreach-single-placeholder#dis-post-555927