0
votes

I have a node/add form.Using hook_form_alter i have added a textfield and a ajax submit button.I do fecth data with that textfiled and button.

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

$form['textfield'] = array(
  '#title' => t('Add Field'),
  '#type' => 'textfield',
  '#required' => true,
  '#weight' => -1,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Field'),
'#weight' => -1,
  '#ajax' => array(
    'wrapper' => 'node-form',
    'callback' => 'submit_callback',
    'effect' => 'fade'
    ),

);

}

and onsubmit of the ajax I am getting the values which I want. But now I want to add few fields of node/add form with the result of that ajax submit.I have got stuck for how to go further with the implementation for this.

Can anyone help me out & let me know how to do this?

1
can you be more specific please?Soni Kishan
you should be knowing about node/add form for any content type.Now on the same node/add form page there is a custom block. it has a textfield and a submit button as i Have mentioned in the above code.On the submit of this block I am getting reponse data.I want to fill the details of the node/add form using the response data of the block. Hope you have got what I want to achieve.Gurjinder Singh
store all data you have submitted in session variable which you can use in second formSoni Kishan

1 Answers

1
votes

I can only think of two options:

1. Store results in $_SESSION.
2. Store results in database (preferably using ctools).

something like this

<?php
$_SESSION['my_data'] = 'somedata';

unset($_SESSION['my_data']);(To unset)
?>

Hope this will help you.