Rashe
June 28, 2016, 3:11pm
1
Hi, I have a form to submit, I cat retrieve all input values except the radio inputs… Here is example:
Form:
<form {{action 'execute' this on="submit"}} class="form">
{{input type="text" value=tokenId}}
{{input type="radio" name="aggregation" value='AVG'}}
{{input type="radio" name="aggregation" value='MAX'}}
<button>Execute</button>
</form>
Controller:
actions: {
execute(){
console.log('e tokenId', this.get('tokenId'));
console.log('e aggregator2', this.get('aggregator'));
}
}
So I need the aggregation input data, witch is selected… I thought I could set default value for input like this:
{{input type="radio" name="aggregation" value=aggregation="MAX"}}
But noway.
heatbr
June 28, 2016, 4:15pm
2
You can default your value in controller hook. The Component Lifecycle - Components - Ember Guides
So you set your ‘aggregatorValue’ to you default value. this.set('aggregatorValue', "MAX")
on initial route/component.
Rashe
June 29, 2016, 5:56am
3
Yes, I can. It will assign values, but how do I get the selected value on submit?
jmimi
June 29, 2016, 6:25am
4
Are you sure you get with correct name??
You set in template aggregation
and get in controller aggregator
Rashe
June 29, 2016, 6:31am
5
As I understood I get value by getting by value… Like this:
{{input type="text" value=tokenId}}
console.log('e tokenId', this.get('tokenId'));
jmimi
June 29, 2016, 6:35am
6
For radio you need to use name
attribute.
Here you get a different property : console.log('e aggregator2', this.get('aggregator'));
Rashe
June 29, 2016, 6:41am
7
{{input type="radio" name="aggregation" value='AVG'}}
{{input type="radio" name="aggregation" value='MAX'}}
Calling for
console.log('e aggregator3', this.get('aggregation'));
Getting ''undefined"
jmimi
June 29, 2016, 7:51am
8
Please check this out : simple radio button
2 Likes