views:

99

answers:

1

I'm using the CodeIgniter reCAPTCHA library (here, forum here). For some reason, no variables are being passed from the reCAPTCHA library to the view that has the reCAPTCHA field code.

Here is my controller (the pertinent parts):

$this->load->library('recaptcha');
$this->load->library('form_validation');
$this->lang->load('recaptcha');

// Validate form
...
$this->form_validation->set_rules('recaptcha_response_field','Captcha','required|callback_captcha_check');

And I've tried loading the field view as a variable:

$data['recaptcha'] = $this->load->view('recaptcha',$data,true);

And within my main view:

<?php $this->load->view('recaptcha');?>

Here is the view code:

<script type="text/javascript">
  var RecaptchaOptions = { 
    theme:"<?= $theme ?>",
    lang:"<?= $lang ?>"
  };
</script>
<script type="text/javascript" src="<?= $server ?>/challenge?k=<?= $key.$errorpart ?>"></script>
<noscript> 
        <iframe src="<?= $server ?>/noscript?lang=<?= $lang ?>&k=<?= $key.$errorpart ?>" height="300" width="500" frameborder="0"></iframe><br/>
        <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
        <input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript>

The library can be found via the links above, but I think it's just a wrapper for the default reCAPTCHA PHP library.

When I access the registration form, the page loads but the reCAPTCHA widget doesn't show up because it throws an error for every variable -- all are undefined.

I'm sure this is something basic about loading variables from a library into a view. Can someone help me out?

A: 

Take a look at the view area of the user guide.

http://codeigniter.com/user_guide/general/views.html

It'll show you how to add dynamic data to a view. You usually would do this in your controller.

someoneinomaha