We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36448
    • 58 Posts
    Hi, I use MODX 2.5.7 and trying to create an easy Doodle (Poll) with FormIt 3.0.2.

    The hook FormItSaveForm saved my forms and with the snippet Rowboat I can read the table:
    [[!Rowboat?
       &table=`modx_formit_forms`
       &columns=`{"values":""}`
       &where=`{"form":"Doodle"}`
    ]]
    


    And I get this json array, like this:
    Array ( [values] => {"name":"Mayer","date1":"0","date2":"1"} [_idx] => 0 [_alt] => 0 [_first] => 1 )
     Array ( [values] => {"name":"Oscar","date1":"1","date2":"1"} [_idx] => 1 [_alt] => 1 [_last] => 1 )
     Array ( [values] => {"name":"Marc","date1":"1","date2":"1"} [_idx] => 1 [_alt] => 1 [_last] => 1 )
     Array ( [values] => {"name":"Carmen","date1":"0","date0":"1"} [_idx] => 1 [_alt] => 1 [_last] => 1 )
     Array ( [values] => {"name":"Peter","date1":"1","date2":"0"} [_idx] => 1 [_alt] => 1 [_last] => 1 )
    


    Rowboat need a tmp chunk with placeholder for that, but I don't know how to do that and I tried a quick snippet for testing:
    $input = json_decode($input);
    return $input->{'name'};


    Unfortunately it's works only with this easy string:
    {"name":"Mayer","date1":"0","date2":"1"}


    Maybe someone can help me how I parse the JSON string with placeholders name, date1 and date2?

    Thanks Jo

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

    [ed. note: krischel last edited this post 6 years, 11 months ago.]
      • 36448
      • 58 Posts
      OK, I'm a little further:

      preg_match_all('/{(.*?)}/', $input, $matches);
      foreach ($matches[1] as $a ){
      $output[] = $output."{".$a."}";
      }
      #echo $output[0];
      #$count = count($output);
      
         $output = json_decode($output[0]);
         return $output->{'name'};


      now I need a "for next loop" for all names... I test it further...
      I this the correct way? Maybe someone has a tip for me?


      add: my test script on sandbox are working, maybe not the best way but it works smiley

      Testlink: sandbox.onlinephpfunctions.com

      [ed. note: krischel last edited this post 6 years, 11 months ago.]
      • discuss.answer
        • 36448
        • 58 Posts
        my own MODX Doodle (scheduling events) with FormIt is running smiley

        Rowboat isn't necessary, Chunk and Snippets on GitHub fiDoodleData



        btw: I deleted my old post because the attachment doesn't work here (link broken and not erasable)

        [ed. note: krischel last edited this post 6 years, 11 months ago.]