0

So I have a dynamically generated form:

<form {{action 'submit' on="submit"}}>
    {{#each model.product.variants as |variant|}}
        <div class="single-product-option-wrapper">
            <div class="row">
                <div class="col-sm-2">
                    <div class="radio">
                      <label>
                        {{input value=optionValue value="{{variant.id}}" type="radio"}}
                        {{model.product.name}}
                      </label>
                    </div>
                </div>
            </div>
        </div>
    {{/each}}
    <button>Submit</button>
</form>

as you can see I'm trying to set the checkbox with the binding of optionValue with what ever the value of {{variant.id}} is. How can I set that value? I'm I just going about it completely the wrong way?

ThreeAccents
  • 1,822
  • 2
  • 13
  • 24

1 Answers1

0

From your code snipit, its not clear what the relationship between the variable "optionValue" and the form is, but to bind value of variant.id to the input helper do this:

{{input value=variant.id type="radio"}}
hewsonism
  • 424
  • 4
  • 11
  • when i grab the properties from my controller `this.get('variant.id')` is undefined – ThreeAccents Jun 02 '15 at 17:57
  • Your original post template suggests your model is something like this: model = { product: {variants: [{id: ...}, ...], name: ...} } The context of your template is the controller, so if you want variant ids in the controller you need something like this: var variants = this.get('model.product.variants'); variants.forEach(function(variant) { console.log(variant.id): }); – hewsonism Jun 02 '15 at 23:13