drupal - Form inside view not working when ajax enabled -


using php field add inside view, form button trigger action related record, work prefect long ajax not enable in view

if enable ajax , use ajax pager , forms in first page working fine, if go next page, click on button , submit handler never called.

    function rs_references_publish_button($reference_id){     $reference_entity=entity_load_single('site_object',$reference_id);     $reference_wrapper = entity_metadata_wrapper('site_object', $reference_entity);     if($reference_wrapper->field_reference_status->value() == 'completed'){      $button=   drupal_get_form('rs_references_publish_button_form',$reference_id);      print drupal_render($button);     }  }  function rs_references_publish_button_form($form, &$form_state){     $form['#action']=  '/'.$_get['q'];// because ajax change action     $form['actions']['reference_publish'] = array(         '#type' => 'submit',         '#id' => 'reference_publish',           '#value' => t('publish'),         '#weight' => 0,     );      return $form; }  function rs_references_publish_button_form_submit($form, &$form_values){      $reference_entity=entity_load_single('site_object',$form_values['build_info']['args'][0]);     $reference_wrapper = entity_metadata_wrapper('site_object', $reference_entity);      $reference_wrapper->field_reference_status->set('published');      $reference_wrapper->save();      drupal_set_message(t('reference published in profile'),'status');  } 

enter image description here

i re debug problem again , found following :

  1. when try click on publish in first page work fine without problem
  2. when click next , go 2nd page , click on publish submit handler called first record not 2nd record, id passed 99 while in 2nd record should pass 100

notice first record not showing publish button because published

when no pager, works fine 100%

the issue must $form_values['build_info']['args'][0] storing first value. should check if there other values in $form_state give entity need. or issue may way putting form view.


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -