FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help?
#1
No matter how much I try to add a single page form through the api it will not work! I am on the first step of the tutorial asking me to add that php code and I always get the error:

Fatal error: Call to undefined function ft_api_init_form_page()

I have the api installed fine, and the require_once path is correct. Help?
Reply
#2
Hmm... it does *sound* like the require_once() path is incorrect, I must confess. That function is defined in api.php, so if the file is included properly you should never see the error.

Try switching between a relative and absolute path and see if that helps.

- Ben
Reply
#3
(May 9th, 2009, 12:57 PM)Ben Wrote: Hmm... it does *sound* like the require_once() path is incorrect, I must confess. That function is defined in api.php, so if the file is included properly you should never see the error.

Try switching between a relative and absolute path and see if that helps.

- Ben

That's what I thought too... but, when I changed the path to something I knew was wrong I got this instead:

"Warning: require_once(/election/database/global/api/api.php) [function.require-once]: failed to open stream: No such file or directory"

So I know the other path was correct (and absolute)

Maybe this will help:

I'm building my website with a CMS called concrete5 and in order to execute code when I website loads it needs to be part of another function. The entire code is here:

PHP Code:
<?php
class CandidatesRegistrationController extends Controller {
    public function 
on_start() {
        require_once(
"http://election.cya-ajc.ca/database/global/api/api.php");
        
$fields ft_api_init_form_page("""test");
        
$params = array(
              
"submit_button" => "submit",
              
"next_page" => "/success.php",
              
"form_data" => $_POST,
              
"finalize" => true
            
);
        
ft_api_process_form($params);
    }
}
?>

Any more thoughts?
Reply
#4
Ah! Any time you include() or require() files you need to use server paths, not URLs. If you can't figure out the right absolute path (I've been there!) try a relative one instead - but make sure its relative from the CALLING page, not the file containing the class. If you're calling that class from multiple pages, you'll need to doctor the class like so:

PHP Code:
<?php
class CandidatesRegistrationController extends Controller {
    public function 
on_start() {
        
$curr_folder dirname(__FILE__);
        require_once(
"$curr_folder/../path/to/database/global/api/api.php");
        
$fields ft_api_init_form_page("""test");
        
$params = array(
              
"submit_button" => "submit",
              
"next_page" => "/success.php",
              
"form_data" => $_POST,
              
"finalize" => true
            
);
        
ft_api_process_form($params);
    }
}
?>

But you'll need to update the relative path in the require_once() call for your setup. What that new code does is always compute the relative path to the api.php file from the file containing the class - not the original file that includes the class file.

Jeez that sounds confusing. Paths are always a nuisance to figure out... maybe the absolute path is the simplest!

- Ben
Reply
#5
Okay now I've got the paths correct. (Checked by my boss as well).

But your script keeps directing the page to error.php, which doesn't exist. Weird?

EDIT:

Oh I see, formtools directs you to this script when there is an error. Unfortunately, the error.php comes up in the same folder as the page itself, not in the formtools directory.

New code:

PHP Code:
<?php
class CandidatesRegistrationController extends Controller {
    public function 
on_start() {
        
$curr_folder dirname(__FILE__);
        require_once(
"$curr_folder/../../database/global/api/api.php");
        
$fields ft_api_init_form_page("""test");
        
$params = array(
              
"submit_button" => "submit",
              
"next_page" => "success.php",
              
"form_data" => $_POST,
              
"finalize" => true
            
);
        
ft_api_process_form($params);
    }
}
?>
Reply
#6
So I figured out from the folks at concrete5 (which, apart from being incompatible with formtools, is a great CMS) that all included scripts must be converted to libraries, which is impractical.

I simply solved this problem by putting the form in an iframe and all the candidate lists and api stuff in pop-ups, which is fine. It actually makes my site a little more clear. But anyways, thanks for your help, everything is working fine now through my workaround. Sorry about posting in the forum and submitting a bug and sending you an email Tongue.

(If you do stumble across a solution though, I'd be curious, but as I said I'm 100% fine with my workaround).
Reply
#7
Hey Steven,

No worries at all - glad it got solved! And sorry for not responding in the bug tracker or here in the forums earlier. SO little time...

I would be interested in learning more about the way concrete5 requires the code, though. Having them as libraries doesn't seem like an outrageous requirement to me.

Another chap has been looking into creating Form Tools as a Joomla mod. Depending on how that goes, it may shed some light on solutions for other scripts. I'll be sure to post here if and when that ball gets rolling.

All the best -

Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)