Form Post On Footer

Hi all!

I’ve the following issue, when I want to retrieve the values of a POST in the controller the values are send like this (var_dump):




array(1) {

  ["Email"]=>

  string(14) "jdoe@gmail.com"

}



This is the form:




<?php 

      $form=$this->beginWidget('CActiveForm',array(

        	'id'=>'suscribete-form',

          	'action'=>array('site/suscribete'),

          	'enableAjaxValidation'=>true,

          	'enableClientValidation'=>false,

          	'clientOptions'=>array(

          		'validateOnSubmit'=>true,

          		'validateOnChange'=>false

          	),

      ));

?>

<div class="input-append">

<?php echo CHtml::textField('Email');?>

<?php echo CHtml::ajaxSubmitButton('Enviar!',

             $this->createUrl('site/suscribete'),

             		array(

             		      'type'=>'post',

             		      'success'=>'js:function(data){

             					if(data!=""){             										         

                                                    $("#resultadosAjax").html(data);

            			                }

             				  }'

             		)

             );

?>

</div>

<?php

     $this->endWidget();

?>



Any idea why this is happening?

what was the problem?

now the value entered in the email field printed on the form submit?

Yes , what is your problem here ?

your value put in $_post array So you saw it like that .

The problem is when I want to retrieve the form value in the controller like this




$model = new Suscribete;


if (isset($_POST['suscribete'])){

   $model->attributes=$_POST['suscribete']

}



the code never enter to the if condition because the $_POST array is not named ‘suscribete’ like the form.

What I’m making wrong?

can you check what is the output of this code?

$model = new Suscribete;

echo ‘<pre>’;

print_r($_POST);

echo ‘</pre>’;

exit;

or

$model = new Suscribete;

echo ‘<pre>’;

print_r($_REQUEST);

echo ‘</pre>’;

exit;