Hi
I am not sure if I do not fully understand how form submission works in DFF or if I am having some other issue, so please bear with me.
I have successfully set up DFF, my canvas page is being displayed and I have also successfully managed to recognize an existing Drupal account when logging in from Facebook. I therefore think I can say that communication is up and running between Facebook and my Drupal installation.
My problems started when I tried to submit forms from the Facebook side. Firstly, whenever I clicked on the submit button in the form, I was redirected to the Canvas Callback URL. Also, the form was never really submitted.
I did some research and the only explanation that I could find was that it is caused by $fb->require_login(), and that I should add $fb->require_frame(). I have subsequently done that in the fb_user.module file.
Now I am not having that problem any more, when I click the submit button, I am returned to my normal canvas page within the Facebook environment.
The problem is now, that the form never gets submitted. It is as if the hook_submit function is never called.
Thanks for any help in advance.
Comments
Comment #1
Dave Cohen commentedFirst you shouldn't have to edit fb_user.module.
Can you reproduce your problem with a form provided by drupal core? For example the story edit form or comment add form?
Comment #2
theobaldr commentedHi Dave
Thanks for the reply.
Editing the fb_user.module was only a crude attempt at trying to get to the bottom of my problem.
I have tried your suggestion with:
drupal_get_form('user_login_block');
It works like a charm!
I have tried a couple of different approaches with my custom form, I even looked at the way the the user_login_block is created. And I really cannot see any major difference between my form and the Drupal core form.
One thing that I did notice, and I hope that is where the problem lies is that when I submit the Drupal core form the following argument is attached to the url "?destination=". That argument is not there when I submit my custom form.
Any idea why that is? And is that my problem?
Thanks again for you help. And thank you for all your effort in creating and maintaining this module.
Comment #3
Dave Cohen commentedWhen you create your own form, what's the action atribute? Use your browser's view source attribute, and show me exactly what the
<form...>tag looks like.Comment #4
theobaldr commentedWhen I access the drupal site directly the form tag looks like this:
form action="/fafigameplay/0" accept-charset="UTF-8" method="post" id="fafigame-iconstoplayform"
When I access from Facebook it looks like this:
form action="http://fafitel.co.za/fb_cb/26/" accept-charset="UTF-8" method="post" id="app216519336656_fafigame-iconstoplayform" fbcontext="1eba6f37667f"
I had to take out the beginning and ending '<' '>' to have it render.
Comment #5
Dave Cohen commentedDo you create the form using form api? Do you specify
'#action'?Comment #6
theobaldr commented1. Yes
2. No
Here is my code: (The menu name is slightly different from the form that I posted before. I was trying a bit of a different approach to try and establish where my problem is)
function facebook_menu() {
$items = array();
$items['fb_fafigameplay/%'] = array(
'title' => 'Play the Fafi Game',
'description' => 'Play the Fafi Game',
'page callback' => 'facebook_fafigame_play',
'page arguments' => array(1),
'access arguments' => array('access facebook content'),
'type' => MENU_CALLBACK
);
return $items;
}
function facebook_fafigame_play($voucherId = ''){
global $user;
$output = "";
if($user->uid == 0) {
drupal_set_message(t("Please register or login to access this page"),"warning");
drupal_set_message(t("These are the dream icons you could choose if you logged in"));
$output .= drupal_get_form('fafigame_iconstoplayform', '0');
return $output;
}
else {
if($voucherId == '0'){
$voucherId ='';
}
$id = getVoucherToPlay(true, $voucherId);
if(($id > 0)&&($id != '')) {
$output .= drupal_get_form('fafigame_iconstoplayform', $id);
return $output;
}
else {
drupal_set_message("Play the Fafi Game for free.");
$output .= drupal_get_form('fafigame_iconstoplayform', "freeplay");
return $output;
}
}
}
function facebook_fafigame_iconstoplayform($form_state, $voucherId){
$form = array();
$form['fafigame_voucherid'] = array(
'#type' => 'hidden',
'#value' => $voucherId,
);
$form['fafigame_icons'] = array(
'#type' => 'radios',
'#title' => t('Select the Fafi Game icon that you whish to play'),
'#options' => getIconsAsArray(true, true),
'#default_value' => 0,
);
//$form['#submit'][] ='fafigame_iconstoplayform_submit';
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit Icon'),
);
return $form;
}
Comment #7
theobaldr commentedAny ideas on this?
Comment #8
theobaldr commentedComment #9
Dave Cohen commentedTried to reproduce, got
If you want my help, paste the complete code I'd need to reproduce the problem. Ideally, not a module, just a chunk of PHP that I can paste into a node body where the input filter is PHP.
When pasting code to these pages, use either
<code>or<?php...?>markup.Comment #10
theobaldr commentedHi Dave
While simplifying my code so it would run on your side I found my problem.
I am sad to say that I was calling the wrong form!!!
Thanks for your dedication and help.