i have a form inside an .inc file. That form i'm calling it inside a new form i'm making, using form_load_include, so far is working but its rendering the external form outside the new form. this is the code that does that:

// start form to create projects
function project_creator_form($form, &$form_state) {
    global $user;
    $uuid = $user->uid;

  form_load_include($form_state, 'inc', 'lc_core', 'location'); //here i call the form
  $renderable = drupal_get_form('location_form', $form_state);
  $location = render($renderable);
  print $location; //here i print the included form

  $form['u_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Identificador de Usuario'),
    '#size' => '6',
    '#attributes' => array('readonly' => 'readonly'),
    '#default_value' => $uuid,
    '#description' => "Este es su identificador de usuario, (no se puede modificar)",

    $form['p_name'] = array(
    '#type' => 'textfield',
    '#title' => t('Nombre de Proyecto'),
    '#required' => TRUE,
    '#description' => "Introduzca el nombre del proyecto.",

    $form['p_type'] = array(
    '#type' => 'select',
    '#title' => t('Seleccione tipo de proyecto'),
    '#options' => array(
      'Obra Nueva' => t('Obra Nueva'),
      'Adecuación' => t('Adecuación'),
      'Remodelacion' => t('Remodelación'),
      'Ampliación' => t('Ampliación'),
      'Refuerzo estructural' => t('Refuerzo estructural'),
      'Mantenimientos' => t('Mantenimientos'),
    '#required' => TRUE,
    '#description' => t('Seleccione el tipo de intervención a relizar.'),

    $form['p_area'] = array(
    '#type' => 'textfield',
    '#title' => t('Area del proyecto (m2)'),
    '#required' => TRUE,
    '#description' => "Ingrese la cantidad de metros cuadrados (m2) del proyecto.",
    '#size' => '6',

  $form['p_desc'] = array(
    '#type' => 'textarea',
    '#title' => t('Descripción'),
    '#description' => "Describa de que se trata el proyecto a ejecutar, puede especificar algunos detalles e información que considere necesaria.",
    '#rows' =>4,
    '#resizable' => FALSE,
    '#required' => TRUE,

    $form['buttons'] = array(
    '#type' => 'submit',
    '#value' => t('Guardar proyecto'),
  return $form;


function project_creator_form_submit($form, &$form_state) {

    db_set_active('civilproconstru'); //OPEN alter DATABASE.
        'u_id' => $form_state['values']['u_id'],
        'p_name' => $form_state['values']['p_name'],
        'p_type' => $form_state['values']['p_type'],
        'p_area' => $form_state['values']['p_area'],
        'p_ctry' => $form_state['values']['p_ctry'],
        'p_dept' => $form_state['values']['p_dept'],
        'p_city' => $form_state['values']['p_city'],
        'p_desc' => $form_state['values']['p_desc'],

$loglink = l("Ver Proyectos", 'admin/lista_de_proyectos');
$msg= "El proyecto $p_name ha sido indexado, continue ingresando información del proyecto en $loglink o puede seguir indexando nuevos proyectos.";

db_set_active(); //CLOSE alter DATABASE.

And this is the output i'm getting: output

Despite i'm printing inside the function that is creating the form drupal it's rendering outside of it...

HOW CAN I FIX THIS???? thanks for the help!...


Instead of printing the form when you load it, create a new form item of type markup and add your subform there as markup.

$form['subform'] = array(
  '#type' => 'markup',
  '#markup' => $location,

This would fix the display order but your submit handler will need to handle the extra items.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.