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

Answered Formit and Migx

    • 40024
    • 72 Posts
    Hi @Bruno17. I have a similar problem. I am using Formit with the resource2formit prehook and a migx tv to allow a user to select a city.

    This is my call:
    [[!FormIt? &preHooks=`resource2formit` &hooks=`spam,formit2resource` &resource2formitfields=`parent,pagetitle,introtext,content,b_city_migx`]]


    And inside my form:

    <label for="b_city_id">Choose your city</label>
    <select id="b_city_id" name="b_city_name">
    [[getImageList? &tvname=`b_city_migx` &tpl=`@CODE:<option value="[[+b_city_migx]]"[[!+fi.b_city_name:is=`[[+b_city_migx]]`:then=`selected`]]>[[+b_city_migx]]</option>`]]</select>


    The resource in the backend is created just fine without any errors in the log EXCEPT the migx area part. I can't get the city values to be passed in the newly created resource in the backend.

    PS: Normal tvs work just fine, but i chose migx cause it offers a more dynamic solution to my client, since it allows him to add as many cities as he likes.
      • 40024
      • 72 Posts
      Hmmm,i just noticed that migx saves its values only in modx_site_tmplvar_contentvalues table, and in a strange format:

      [{"MIGX_id":"3","b_city_migx":"New York"},{"MIGX_id":"1","b_city_migx":"London"}]


      Is there any way to get those values via the api and filter them so they can only show the values "New York" and "London"? Or maybe is there a better approach? Sorry, all this migx, resource2formit-formit thing has greatly confused me :/
        • 4172
        • 5,888 Posts
        well, the format isn't that strange. Its just JSON
        http://www.json.org/

        I'm not sure to understand what you are trying todo at all.

        where do you want to get these values? "New York" and "London"
        where and why are you trying to save them from frontend?

        with
        <select id="b_city_id" name="b_city_name"> 

        you get a string, which you can save in a normal Text-TV.

        Think I get something wrong, about what you are trying.

          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 40024
          • 72 Posts
          Thank you for your quick response smiley
          Let me apologize and explain further:
          The manager user(my client) wants to be able to add as many cities as he likes in a easy way in the backend(migx provides that dynamic fuctionality). Those cities then appear in a page the front end where a web user can add his store and select a city as to where his store is. Since the web user is the one that creates his store, i used the resource2formit snippet to allow him to create resources in the manager from the front-end(i don't want web users to be able to log in the backend).

          I want the city that the web user selects in the "add your store" page,to be passed in the newly created resource, so when the manager user logs in he will just publish the newly created resource if it checks ok(if it is valid store and stuff [that has nothing to do with modx or me]).

          I am not sure if i have given you enough info to understand my issue. Did these clarify things a little better?
          • Isn't there some kind of multi-tag plugin that would do this? In the back-end, the editors can add all the cities they want, while the front-end would fetch the "tags" and make the select out of the list.

            Of course, MIGx can do the same thing... it saves the list as a JSON string, which can output its list as select options or radio buttons or whatever you want. It's all in the tpl used for getImageList.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 40024
              • 72 Posts
              You mean something like what multi-tv did for evo? So far all i have found is migx. The issue arises in the newly created resource that the web user creates.
              For example see attached screenshots below:

              The "add your store.jpg" is where the manager user adds the cities that will be displyed in the front end(which they do,and so far so good) and the "test_store.jpg" shows that the migx tv is empty after a web user has created a new resource via the front end(with the resource2formit-formit2resource formit prehooks) and has selected a city.

              I am starting to think that maybe the resource2formit-formit2resource snippets are missing something when they are getting the tv values.

              http://imageshack.us/photo/my-images/708/addyourstore.jpg/
              http://imageshack.us/photo/my-images/838/teststore.jpg/

              [ed. note: dinpapa last edited this post 11 years ago.]