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

    I’ve successfully managed to have a a snippet execute and echo out the needed data into an option drop down to select a preset value and name from a MySQL db but when I try to $modx->SetPlaceholder($application_name,$application_options); it doesn’t make it back into the form.

    I’m having a closer look at the above example of how to get TV values into a form, I imagine this will need similar steps to be taken to get it working but is there a way to allow these snippet set placeholders to show inside the form as an option?

    Many thanks

    Jamie Murray
      p i x e l p u s h e r e x t r o d i n a i r e
      A x i s A n i m a t i o n . c o m
      • 10449
      • 956 Posts
      This may be just a case of wrong capitalization:

      use $modx->setPlaceholder();
      instead of
      $modx->SetPlaceholder();

      (lowercase s - "camel case" notation)
        • 30884
        • 142 Posts
        Fraid it’s not. I went back and checked. I just typed it wrong in the above post. It’s ok though. I’ve been looking at how to work with template vars and having them injected into the &$template string in the stickied topic above. Think I’ll give that a try today.
        Cheers

        Jamie
        laugh

        Update: Works a treat. Seems that loading up the &$templates and &$fields into the mysql function I’m using to populate the drop downs works fab when I scavenge the code to inject/replace the placeholders in the chunk/tpl of the form. All i did was take the MySQL result (compiled into a form element already for use on the placeholder code) then search and insert using the code from the above sticky about having TV’s into a form.

        // REVISED INJECTION Method.
                /*
                $modx->setPlaceholder($app_field_prefix, $application);
                $modx->setPlaceholder($app_list_placeholder, $result);
                $modx->setPlaceholder($app_select_placeholder, $selectbox);
                $modx->setPlaceholder('axref', $axref);
                */
                //  Example line below used to retrieve TV's into a form.
                ///$templates['tpl'] = str_replace('[+display_tv_options+]', $options, $templates['tpl']);
                $templates['tpl'] = str_replace('[+List_' . $app_field_prefix . '+]', $selectbox,$templates['tpl']);
                $templates['tpl'] = str_replace('[+axref+]', $axref, $templates['tpl']);
                $templates['tpl'] = str_replace('[+'.$app_field_prefix.'+]',$application,$templates['tpl']);
        


        Magic! Works a treat. I can now get onto the form layout and behaviours etc.
          p i x e l p u s h e r e x t r o d i n a i r e
          A x i s A n i m a t i o n . c o m