Dear all,
I am using jquery to submit the form to a specifc action.
However, in the controller, I can’t get all the post value at all.
Here is my code:
//jquery:
function facebook(){
$("#first-form").attr("action", "/yiiauth/default/authenticatewithfacebook");
$('#first-form').submit();
}
function gmail(){
$("#first-form").attr("action", "/yiiauth/default/authenticatewithgoogle");
$('#first-form').submit();
}
</script>
//controller:
public function actionauthenticatewithfacebook() {
$provider="facebook";
$hybridauth_config =Yiiauth::hybridAuthConfig();
$error = false;
$user_profile = false;
try{
// create an instance for Hybridauth with the configuration file path as parameter
$hybridauth = new Hybrid_Auth( $hybridauth_config );
$adapter = $hybridauth->authenticate( $provider );
$user_profile = $adapter->getUserProfile();
}
catch( Exception $e ){
// Display the recived error
switch( $e->getCode() ){
case 0 : $error = "Unspecified error."; break;
case 1 : $error = "Hybriauth configuration error."; break;
case 2 : $error = "Provider not properly configured."; break;
case 3 : $error = "Unknown or disabled provider."; break;
case 4 : $error = "Missing provider application credentials."; break;
case 5 : $error = "Authentification failed. The user has canceled the authentication or the provider refused the connection."; break;
case 6 : $error = "User profile request failed. Most likely the user is not connected to the provider and he should to authenticate again.";
$adapter->logout();
break;
case 7 : $error = "User not connected to the provider.";
$adapter->logout();
break;
}
}
// workOnUser returns an user object
if ( is_object ($user_profile) ){
$user = $this->workOnUser($provider,$user_profile->identifier);
if ( $this->autoLogin($user) ){
if(isset($_POST['Prequestions'])|| isset($_POST['Prequestions[name]'])) //here is the post
{
$questions = new Questions;
$questions->attributes=$_POST['Prequestions'];
$questions->save();
}else{
throw new CHttpException(404,"Didn't receive any post at all.");
}
Hybrid_Auth::redirect('/user/profile');
}else{
// this is where u go otherwise
$this->render('authenticatewith',array('error'=>$error,'user_profile'=>$user_profile ) );
}
}else{
echo "Something wrong with ".$provider;
}
}
My form is rendered by another controller
The id of the form is called "first-form", and the name of the field is something like Prequestions[name] Prequestions[description]…etc.
Any ideas about how to get the post data here…?
Right now it keeps telling me didn’t receive any post at all.