0

I need to create a sign up form that also displays all of the submitted values above each value on the same page. I have searched for hours and cannot find anything that describes how to achieve this. So it would be formatted like:

Sign Up Form

Results of value 1:

value1, user 1

value1, user 2

value1, user 3

[enter value for value1] <= this is the form field to enter a new value1 for current user

Result of value 2:

value2, user 4

value2, user 2

value2, user 6

[enter value for value1] <= this is the form field to enter a new value1 for current user

[submit]

I have come close with webform and building a webform-form--nid.tpl.php file to override the default template, and use views to create tables for the results but the view tables are listing all of blank fields as well. I have tried entitfyform but don't know how to split up the form to allow to have the views above each relevant section.

0

Sign Up Form

<?php
    function formfun_menu() {
    $items = array();
    $items['formfun'] = array( //this creates a URL that will call this form at "examples/form-example"
    'title' => 'FORM FUN',
    'description' => 'A form to mess around with.',
    'page callback' => 'drupal_get_form', //this is the function that will be called when the page is accessed.  for a form, use drupal_get_form
    'page arguments' => array('formfun_form'), //put the name of the form here
    'type' => MENU_NORMAL_ITEM,

    'access callback' => TRUE
  );
  return $items;
}

function formfun_upload_form($form, &$form_state) {

$form['add'] = array(
 '#type' => 'fieldset',
'#title' => t('Add company details'),
);
  $form['add']['companyname'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => 'Company Name',
  );

  $form['add']['contactname'] = array(
    '#type' => 'textfield',
    '#required' => TRUE,
    '#title' => 'Contact Name',
  );

    $form['add']['companyaddress'] = array(
    '#type' => 'textarea',
    '#required' => TRUE,
    '#title' => 'Contact Address',
  );

    $form['add']['postalcode'] = array(
    '#type' => 'textfield',
    '#title' => 'Postal Code',
  );

    $form['add']['city'] = array(
    '#type' => 'textfield',
    '#title' => 'City',
  );

    $form['add']['country'] = array(
    '#type' => 'textfield',
    '#title' => 'Country',
  );

    $form['add']['file'] = array(
        '#type'     => 'file',
        '#title'    => t('Choose a file'),  
);

  $form['add']['submit_button'] = array(
    '#type' => 'submit',
    '#value' => t('Click Here!'),

  );
   return $form;
}

function formfun_submit($form, &$form_state) {

    echo '<pre>';
var_dump($form_state['values']);
echo '</pre>';

    db_insert('details')
    ->fields(array(
    'companyname' => $form_state['values']['companyname'],
        'contactname' => $form_state['values']['contactname'], 
        'companyaddress' => $form_state['values']['companyaddress'], 
         'postalcode' => $form_state['values']['postalcode'],  
        'city' => $form_state['values']['city'],  
         'country' => $form_state['values']['country'],  
         'image' => $form_state['values']['file'],
   ))
   ->execute();
    drupal_set_message("successfully saved Security Settings"); 
    exit();
}

function formfun_validate($form,&$form_state) 

{
  }

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.