I'm trying to create a multiple choice class where I pass in the question and anywhere from 2 to 8 possible answers from which the user must choose one. How can I dynamically pass my items to my class, and create a new radiofield for each possible answer? Here's my current class with two possible answers (Red, White)
Ext.define('Sencha.view.question.QuestionTypeOne', { extend: 'Ext.Container', xtype: 'question-type-one', requires: [ 'Ext.TitleBar' ], config: { height: '250px', width: '250px', items: [ { xtype: 'fieldset', title: 'What\'s your favorite color?', instructions: 'Select one', defaults: { xtype: 'radiofield', labelWidth: '40%' }, items: [ { name: 'color', value: 'red', label: 'Red' }, { name: 'color', value: 'white', label: 'White' } ] } ] }, initialize: function () { this.callParent(arguments); } });
And it would be invoked something like this?
{ xtype: 'question-type-one', // question: "What's your favorite color?", // items: [] }