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

is possible create my own entities #801

Open jomarocas opened 8 years ago

jomarocas commented 8 years ago

Hi i want create custom module for create own entities, i want alter my own custom form and create this form with custom entities, that i need modify, but my question, i can use the default entities for my custom form? i want edit an alarm, delete alarm, ut i cannot use the defaults fields of drupal, i need create my own entities this is my custom form.

ok i forget tells, the data is for save in localstorage


function custom_module_medicamentos_form(form, form_state) {
  try {
    var urlsubmit = "_drupalgap_form_submit('custom_module_medicamentos_form');";
    var useruid = Drupal.user.uid;

    form.elements['titulo-medicamentos'] = {
      type: 'textfield',
      title: 'Nombre medicamento',
      required: true,
      title_placeholder: true,
    };
    var medicamentodate = '<label for="label-date-start-event-medicamento">Fecha de inicio medicamento</label>  <input type="date" onchange="medicamentosvaluedatestart()" id="medicamentos-begin" required></input>';
    form.elements['fecha-medicamento'] = {
      markup : medicamentodate
    };

    var hourmedicamento = '<label for="label-date-hour-begin-event-medicamento">Inicio toma de medicamento</label>  <input type="time" onchange="medicamentoshourbegin()" id="medicamentos-time-begin" required></input>';
    form.elements['hour-begin'] = {
      markup : hourmedicamento
    };

    form.elements['recordar-medicamentos'] = {
      title: 'Recordar cada cuanto',
      type: 'select',
      options: {
        300: '5 horas',
        360: '6 horas',
        480: '8 horas',
        600: '10 horas',
        day: 'dia',
        5: '5 minutos',
      },
      default_value: 0
    };
    form.elements['descripcion-medicamentos'] = {
      type: 'textarea',
      title: 'Descripcion del medicamento',
      required: true,
      title_placeholder: true,
    };
    form.elements['uid'] = {
      type: 'hidden',
      default_value:useruid,
    };
    form.elements['enviar'] = {
      type: 'submit',
      value: 'Guardar recordatorio medicamento'
    };
    return form;
  }
  catch (error) { console.log('custom_module_medicamentos_form - ' + error); }
}
function my_module_menu() {
    var items = {
      'medicamentos-list': {
        'title': t('Content'),
        'page_callback': 'alarma_page',
        'pageshow': 'alarma_page_pageshow'
      },
      'medicamentos/%': {
        'title': t('Medicamentos'),
        'page_callback': 'medicamentos_page_view',
        'page_arguments': [1],
        'pageshow': 'node_page_view_pageshow',
        'title_callback': 'node_page_title',
        'title_arguments': [1]
      },
      'medicamentos/%/view': {
        'title': t('View'),
        'type': 'MENU_DEFAULT_LOCAL_TASK',
        'weight': -10
      },
      'medicamentos/%/edit': {
        'title': t('Medicamentos Editar'),
        'page_callback': 'entity_page_edit',
        'pageshow': 'entity_page_edit_pageshow',
        'page_arguments': ['custom_module_medicamentos_form', 'node', 1],
        'weight': 0,
        'type': 'MENU_LOCAL_TASK',
        options: {reloadPage: true}
      }
    };
    return items;
}
signalpoint commented 8 years ago

@jomarocas Sorry for the delay on this. I've actually just added a new feature that will make this much easier. See these docs:

It's now really easy to deliver entities to a page_callback or form builder function. Grab the latest drupalgap.min.js for the feature though.