0
Welcome Guest! Login
0 items Join Now

Simple array in particle

    • V-Web's Avatar
    • V-Web
    • Rocketeer
    • Posts: 91
    • Thanks: 0

    Simple array in particle

    Posted 7 years 5 months ago
    • I need a simple array in my particle and I want to prevent another form popup with the input. Using the collection.list basically does what I need however I need to add fields that eventually opens a new form. I just want to hit the "+" button, fill in the field and that's it. Then loop through in the html.twig file.

      I want it to allow users to add listitems to an unordered list. So adding items should be as simple as possible.
    • Matt's Avatar
    • Matt
    • Preeminent Rocketeer
    • Posts: 21555
    • Thanks: 3090
    • messin' with stuff

    Re: Simple array in particle

    Posted 7 years 5 months ago
    • I about halfway understand the request...

      At one point you say you want to prevent another forum popup... then you say you eventually need the fields to open a new form?

      The description field of your collection... "My text" and "My text 2" --- those are values you can grab/use... you don't need the user to necessarily click on "My text" and enter their inputs there... you can use "My text" straight from the collection item title
    • SEARCH the forum first! These boards are rich in knowledge and vast in topics. This includes searching just the 'Solved' forums, using Google, and using ChatGPT :woohoo:
    • V-Web's Avatar
    • V-Web
    • Rocketeer
    • Posts: 91
    • Thanks: 0

    Re: Simple array in particle

    Posted 7 years 5 months ago
    • Hi Matt,

      I think you completely understand what I mean and I got it working for like 50% but I seem to be missing something, somewhere. Using the collection.list is the way to go as I understand, so I construct the following YAML piece:
      .lists:
          type: collection.list
          array: true
          label: List Items
          description: Create each List item to display.
          value: lists
          ajax: true

      Now I have the input in the particle and I can add as many as I want. However, I can still click on each input, or lists for that matter and it returns the input form of the particle itself. Saving the particle actually deletes all input I have made. The html.twig file part looks as follows:
      <ul>
          {% for listitem in item.lists %}
      		<li>{{ listitem.lists|raw }}</li>
          {% endfor %}
      </ul>
    • Last Edit: 7 years 5 months ago by V-Web.
    • V-Web's Avatar
    • V-Web
    • Rocketeer
    • Posts: 91
    • Thanks: 0

    Re: Simple array in particle

    Posted 7 years 5 months ago
    • Okay, so got it working a bit more, here's my code:

      YAML
      .lists:
                type: collection.list
                array: true
                label: List Items
                description: Create each List item to display.
                value: lists
                ajax: true
      
                fields:
                  .listslink:
                    type: input.text
                    label: Something
                    description: Something
                    placeholder: Something

      HTML.TWIG
      <ul>
      	{% for listitem in item.lists %}
      		<li>{{ listitem.lists|raw }}</li>
      	{% endfor %}
      </ul>

      This way I can retrieve the actual list item from the front form. I do need at least one field for the collection list to have this working. Next step, how to make this field unnecessary and not having an additional popup form showing...
    • Matias Griese's Avatar
    • Matias Griese
    • Sr. Rocketeer
    • Posts: 249
    • Thanks: 104
    • Lead Developer

    Re: Simple array in particle

    Posted 7 years 5 months ago
    • The field collection.list is really not to meant to have only single item (though it does work with it), so there's no logic to disable the popup for simple items. Its not a bad idea though (I can see when it might be useful), so please go and add an issue to github at github.com/gantry/gantry5/issues . :)
    • The following users have thanked you: Matt

    • Gantry 5, enjoy!
    • V-Web's Avatar
    • V-Web
    • Rocketeer
    • Posts: 91
    • Thanks: 0

    Re: Simple array in particle

    Posted 7 years 5 months ago

Time to create page: 0.063 seconds