signalpoint / DrupalGap

An application development kit for Drupal websites.
https://www.drupalgap.org
GNU General Public License v2.0
232 stars 186 forks source link

custom form displaying undefined for radios options #646

Open days4 opened 8 years ago

days4 commented 8 years ago

hi, i am making a custom form in my drupalgap application there is a field of type radio button .On accessing this form radio button is displaying undefined.Code for that form is shown below

function mymodule_custom_form(form, form_state) {
  try {
    form.elements['bet_amount'] = {
      type: 'textfield',
      title: 'Amount to bet',
      required: true
    };
    form.elements['selected_outcome'] = {
      title: 'Selected Outcome',
      type: 'radios',
      options: {
            0: 'Rock and Roll',
            1: 'Metal'
                },
      default_value:1
    };
    form.elements['node_id'] = {
      type: 'hidden',
      default_value: '',
      required: true
    };
    form.elements['user_id'] = {
      type: 'hidden',
      default_value: '',
      required: true
    };

    form.elements['submit'] = {
      type: 'submit',
      value: 'Say Hello'
    };

    return form;
  }
  catch (error) { console.log('mymodule_custom_form - ' + error); }
}
function mymodule_menu() {
  try {
    var items = {};
    items['my_form'] = {
      title: 'Place Bet Form',
      page_callback: 'drupalgap_get_form',
      page_arguments: ['mymodule_custom_form']
    };
    return items;
  }
  catch (error) { console.log('mymodule_menu - ' + error); }
}
signalpoint commented 8 years ago

@days4 works for me on the latest of everything:

screenshot from 2015-10-15 10 23 29

Watch your JS console log in your browser's developer tools, it may reveal some JS error(s) related to this.