Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing arguments using drupal_get_form()
    text
    copied!<p>Here is my custom module using hook,</p> <p>Assume if I want to pass argument to custom1_default_form function call, how should i pass the argument?</p> <pre><code>&lt;?php function custom1_block($op,$delta=0){ if($op=='list'){ $block = array(); $block[0]['info']=t('hello world'); return $block; }else if($op=='view'){ $block_content = '&lt;p&gt;THIS IS MY FIRST BLOCK&lt;/p&gt;'; $block['subject'] = 'HELLO WORLD'; $block['content'] =drupal_get_form('custom1_default_form'); return $block; } } function custom1_default_form () { $form = array(); $form['nusoap_urls']['txt_name'] = array('#type' =&gt; 'textfield', '#title' =&gt; t('Please enter your name'), '#default_value' =&gt; variable_get('webservice_user_url',''), '#maxlength' =&gt; '40', '#size' =&gt; '20', // '#description' =&gt; t('&lt;br /&gt;Root directory used to present the filebrowser user interface.') ); $form['submit'] = array( '#type' =&gt; 'submit', '#value' =&gt; t('Save Details'), ); return $form; } function custom1_default_form_validate (&amp;$form, &amp;$form_state) { if(($form_state['values']['txt_name']) == '') { form_set_error('user_webservice', t('Enter a name')); } } function custom1_default_form_submit ($form_id, $form_values) { // drupal_set_message( print_r($_POST)); // $message = 'You have submitted the ' . $form_id . ' form which contains the following data:&lt;pre&gt;' . print_r($form_state['values'],true) . '&lt;/pre&gt;'; //drupal_set_message(t($message)); //drupal_set_message(t($form_values['values']['txt_name'])); // print_r($form_values['values']); $GET_TXT_FIELD_VALUE = $form_values['values']['txt_name']; $INSERT_QUERY = "INSERT INTO sample (test_name) VALUES ('$GET_TXT_FIELD_VALUE')"; if (db_result(db_query("SELECT COUNT(*) FROM {sample} WHERE test_name = '%s';", $GET_TXT_FIELD_VALUE))) { // User doesn't exist drupal_set_message(t('ALREADY EXIST.....')); }else{ db_query($INSERT_QUERY)or die('Execution Failed'); if(db_affected_rows()==1){ drupal_set_message(t('VALUE INSERTED SUCCESSFULLY')); }else{ drupal_set_message(t('VALUE INSERTED FAILED')); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload