0

I added fields mobile no,landline no, using the below code to the form which i created with webform module. when i fill the fields along with two added fields and submit them .i cannot find the two added field in results.how can i make them appear in results.

function search_enhance_form_alter(&$form, $form_state, $form_id) {

if($form_id == 'webform_client_form_2') {
  $form['mobile no'] = array(
  '#type' => 'fieldset',
  '#title' => t('mobile no'),
  '#collapsible' => TRUE,
  '#weight' => 30,
);
$form['mobile no']['text'] = array(
  '#type' => 'textfield',
  '#description' => t('This is a test to see the form_alter hook in action1.'),
);

$form['text'] = array(
  '#type' => 'textfield',
  '#description' => t('This is a test to see the form_alter hook in action.'),
  '#title' => t('land line no'),
  '#weight' => 10,
);
}         
}
1
  • 2
    Have you considered adding those fields through the user interface instead of in custom code? Then all the data saving is handled for you. Based on the code example you provided I would think you don't need custom code.
    – rooby
    Nov 25, 2014 at 9:10

1 Answer 1

-1

first create submit button

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

when you create submit it calls this function and feilds submitted or updated to your database

function form_try_form_submit($form, &$form_state) 
            {
                echo '<pre>';
                var_dump($form_state['values']);
                echo '</pre>';
                $insert=db_insert('DB')
                ->fields
                (
                    array
                    (
                        'phone' => $form_state['values']['phone']
                                 ) 
                 )
            }  
1
  • The OP is altering an existing form. There is not need to add another submission button to the form, since there is one already. Plus, the OP's problem is not seeing the added form fields in the form.
    – apaderno
    Nov 25, 2014 at 11:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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