I GET THE MODAL FORM POPUP,ITS showing well.
when i submit, a value on validation everything works well,i mean the error messages are displayed on the form.
but when is reaches the submit i am getting this error "An AJAX HTTP error occurred. HTTP Result Code: 200".
with if logged in as adminstrator it shows lots of debugging informations which i dont understand. I have attached a Screen shot for both on validation and on submit.
THE STRANGE THING IS THAT THE VALUES ARE SAVED TO THE DATABASE...SO I GUESS THERE MUST ISSUE WITH REDIRECT!!
HELP PLA

//here is my validate function

/***
 *implementation of hook_validate()
 *@ $form_state takes the current state of a form and the submited values
 *@ &$form we are also passing the whole drupal form as a refference
 *Validate the kupon number submitted by user
 */
function freechuz_get_kupon_form_validate(&$form,$form_state){
        
         $productid=$form_state['values']['product_id'];
         $submitted_coupon=$form_state['values']['coupon_qty'];
	 $coupon_left=coupon_left($productid);
	 if (!is_numeric($submitted_coupon)) {
	    form_set_error('coupon_qty',t('You must enter a number for the kupon'));
	}elseif (($submitted_coupon)<1){
	    form_set_error('coupon_qty',t('The value of Kupon must be greater than Zero.'));
	}elseif($productid<0){
	  form_set_error('coupon_qty',t('Sorry product number undifined, try again later'));
	}elseif($coupon_left==0){
	  form_set_error('coupon_qty',t('Вы уже получили этот купон!'));
	}
}

//implemenation of hook_submit()

/**
 *submit the kupon to database via hook_submit 
 */
function freechuz_get_kupon_form_submit(&$form,$form_state){
    global $user;
    global $base_path;
  
    //call the submit coupon function
   if(submit_kupon($form_state['values']['product_id'],$form_state['values']['coupon_qty'])){
    drupal_set_message(t('Купон получен!!! Ваш купон доступен в uid.'/freechuzkupon">личном кабинете.
')); }else{ drupal_set_message(t('Sorry something went wrong, try again later
')); } } /*********submit function**********/ /** *submit the kupon to database *@param $productid the id of the product or simply nodeid *@param $coupon_qty how many coupons per product */ function submit_kupon($productid,$submitted_coupon){ global $user; $counter=0; $coupon_left=coupon_left($productid); //left coupon $result=''; if(($submitted_coupon<=$coupon_left)){ /** * update the coupon sold value for user with the submitted values */ $node=node_load($productid); //load the node $node->field_coupon_sold['und'][0]['value']=$node->field_coupon_sold['und'][0]['value']+$submitted_coupon; print 'coupon sold '.$node->field_discount_value['und'][0]['value']; node_save($node); //then update, save the node /***end of update coupon sold***/ while($counter<=($submitted_coupon-1)){ $coupon_number=coupon_generate(16);//generate the coupon $result=db_insert('freechuz_coupon') ->fields(array( 'coupon_number' =>$coupon_number, 'content_id' => $productid, 'coupon_qty' => $submitted_coupon, 'deleted' => 0, 'user_id' =>$user->uid )) ->execute(); //in the future will add a unique number(generated from coupon id) to each coupon generated $counter++; } } if($result){ return true; }else{ return false; } }

?>

Comments

capellic’s picture

I am having the same problem here: #1422002: How do I use with a node form?

mrcniceguy’s picture

@capellic i am also still waiting for Help!!!

capellic’s picture

I got ahold of Sam Kottler in IRC in the #drupal-nyc room. Here is the relevant part of the discussion.

[09:40am] capellic: samkottler: The form appears, I can submit, the node gets created, but then I get a "HTTP Result Code: 200" error. You've had success?

[09:42am] samkottler: capellic: yes, I wrote a little chunk of JS that closes the modal after the node submission is complete

[09:47am] samkottler: capellic: I took some amount of code from http://stellapower.net/content/ajax-ifying-drupal-node-forms

[09:51am] samkottler: capellic: lol, that's all PHP and does some heavy alteration, the magic is in the ajax form handler, album_ajax_form_handler()

mrcniceguy’s picture

@Cappelic,thankx again for this nice tutorial link.

but now am using the Dialog Api module,which also uses the ctools but with jquery dialog.. am liking it.
i found this wonderful tutorial which lead me to succeed.

http://pixeljets.com/blog/improving-user-experience-using-dialogs-profil...

wojtha’s picture

The current version of CTools Automodals is missing the form submission handling.

You can try the patches here: #1420534: Consider a new hook - hook_ctools_automodal_paths() rather than using hook_menu() or here: #1396272: Handle submitted forms.