Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MultiAdd: Multiple groups of variant radio buttons in a template #13

Open
wileykoepp opened this issue Sep 27, 2017 · 2 comments
Open

Comments

@wileykoepp
Copy link

Trying to include multiple products in a template with variants in groups of radio buttons. The problem is that MultiAdd utilizes the name attribute of the input, making each name unique. Code snippet follows. I need to either:

  1. Find a way to have MultiAdd work with matching/grouped name attributes
  2. Find another way to group radio inputs while having name attributes with unique names
        {% set itemsIndex = 0 %}
        {% for product in entry.productType %}
            {% for variant in product.variants %}
                {% set itemsIndex = itemsIndex + 1 %}
                <input type="hidden" name="items[{{ itemsIndex }}][purchasableId]" value="{{ variant.id }}">
                <label class="radioLabel"><input type="radio" name="items[{{ itemsIndex }}][qty]" value="1"> {{ variant.title }}</label>
            {% endfor %}
        {% endfor %}
@bossanova808
Copy link
Collaborator

Hmm, yeah that is a good point. Don't use radios myself as it happens. You could basically use a checkbox and some js to achieve the same I suppose, or some JS to manipulate the name of the checked thing before submitting the form, but that requires JS, and it's not ideal really.

We should have perhaps used a data-name type of thing eh @engram-design ? But sincew this was just a wee hack that grew into a now quite often and widely used thing, it would be a bit of a breaking change. Although we could implement it as a fallback perhaps?

What do you think Josh?

(Also there's a few commits etc. in master that really should be released, to do with the deprecated commerce db stuff....)

@bossanova808
Copy link
Collaborator

@engram-design Thoughts on ^ ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants