Note that there are some explanatory texts on larger screens.

plurals
  1. POAjax Not working in custom theme in drupal 7.x
    primarykey
    data
    text
    <pre><code>&lt;?php /** hook_menu **/ function example_contact_form_menu() { return array( 'contact_form_test' =&gt; array( 'page callback' =&gt; 'contact_form_test', 'page arguments' =&gt; array(), 'access arguments' =&gt; TRUE, 'type' =&gt; MENU_CALLBACK, ), 'contact_form_test_1' =&gt; array( 'page callback' =&gt; 'drupal_get_form', 'page arguments' =&gt; examplexample_contact_form_form'), 'access arguments' =&gt; TRUE, 'type' =&gt; MENU_CALLBACK, ) ); } function contact_form_test() { drupal_add_css(drupal_get_path('module', 'example_contact_form') . '/example_contact_form.css'); dpm(drupal_get_form('example_contact_form_form')); return render(drupal_get_form('example_contact_form_form')); } /** * Implementation of hook_form(). */ function example_contact_form_form($form, &amp;$form_state){ $form=drupal_build_form('example_form_form',$form_state); $form['first_name']['#size']=25; $form['last_name']['#size']=25; unset($form['submit_form']); //adding new fields $form['box'] = array( '#type' =&gt; 'markup', '#prefix' =&gt; '&lt;div id="box"&gt;', '#suffix' =&gt; '&lt;/div&gt;', '#markup' =&gt; '&lt;h1&gt;Initial markup for box&lt;/h1&gt;', ); $form['comment'] = array( '#title'=&gt; t('Comments'), '#type' =&gt; 'textarea', '#value'=&gt;'Type Here', '#description' =&gt; t(''), '#default_value' =&gt; '', '#attributes'=&gt;array( 'onfocus'=&gt; "if(this.value=='Type Here')this.value='';" ) ); $form['questions'] = array( '#type' =&gt; 'select', '#title' =&gt; t('Whats in your mind'), '#default_value' =&gt; array(), '#options' =&gt; array( 'What\'s in your mind' =&gt; 'What\'s in your mind', 'Question 1' =&gt; 'Question 1', ), ); $form['sub_form'] = array( '#type' =&gt; 'button', '#ajax' =&gt; array( 'callback' =&gt; 'example_contact_form_js', 'wrapper' =&gt; 'box', 'name' =&gt; 'submit1', ), '#value' =&gt; t('Submit'), ); unset($form['#theme']); $form['#theme'] = array('example_form_form', 'contact_theme_form'); $form['#validate'] = array('example_contact_form_form_validate'); $form['#submit'] = array('example_contact_form_form_submit'); return $form; } function example_contact_form_form_validate($form, &amp;$form_state){ dpm($form_state,t('Form State Validate')); } function example_contact_form_js($form, &amp;$form_state){ $element = $form['box']; $element['#markup'] = "Clicked submit ({$form_state['values']['op']}): " . date('c'); return $element; } function advanced_form_callback($form, &amp;$form_state) { $city_name = form_result_helper($form_state); $element = $form['status']; $element['#markup'] = t('You submitted @city', array('@city' =&gt; $city_name)); print 'BHASKAR'; } function example_contact_form_form_submit($form, &amp;$form_state){ dpm($form_state,t('Form State Submit')); } // Menu callback function example_contact_form_theme(){ return array ( 'contact_theme_form' =&gt; array ( 'render element' =&gt; 'form', 'template' =&gt; 'contact-signup', 'path' =&gt; drupal_get_path('module', 'example_contact_form').'/templates', 'arguments' =&gt; array('form' =&gt; null), ), ); } function template_preprocess_contact_theme_form(&amp;$variables) { $form=$variables['form']; foreach (element_children($form) as $key) { unset($form[$key]['#title']); $variables[$key]=render(($form[$key])); unset($form[$key]); } $variables['contact']=drupal_render_children($form); } ?&gt; </code></pre> <p>Problem is when i tried to render each element in template_preprocess_contact_theme_form i i remove this function everything seems to be working. Can anybody help me on this issue ?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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