We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51347
    • 82 Posts
    Hello community,

    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>
    

    This question has been answered by Bruno17. See the first response.

    • discuss.answer
      • 4172
      • 5,888 Posts
      $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;
      
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 51347
        • 82 Posts
        It works great! Thank you Bruno.