[eluser]Michael Wales[/eluser]
I've used this method before - I have no idea why it isn't working at the moment (maybe a change in 1.6.3?).
Anyone mind giving me a second look to see if they can determine why my callback function is not being called?
View:
Code:
<?php echo form_open_multipart('apply/' . $job->id, array('id'=>'apply')); ?>
<fieldset>
<legend>Your Information</legend>
<p><label for="name">Your Name:</label><br /><input type="text" name="name" id="name" maxlength="120" /></p>
<p><label for="email">Your Email:</label><br /><span class="tip">Your email address will not be published and we'll never spam you.</span><input type="text" name="email" id="email" maxlength="120" /></p>
<p><label for="cv">Cover Letter:</label><br /><textarea name="cv" id="cv" cols="50" rows="10"></textarea></p>
</fieldset>
<fieldset>
<legend>Upload Your Resume</legend>
<p><input type="file" name="resume" id="resume" />
<span class="tip">Accepted file formats are: DOC, PDF, RTF, and TXT.</span></p>
</fieldset>
<p><input type="submit" name="btnApply" id="btnApply" value="Send Application" /> or <?php echo anchor('job/' . $job->id . '/' . url_title($job->title), 'Cancel'); ?></p>
<input type="hidden" name="resume_v" />
<?php echo form_close(); ?>
Controller:
Code:
function apply($id = NULL) {
// Make sure we have an ID to use
if ($id === NULL) {
redirect('');
return;
}
// Validation
$this->load->library('validation');
$this->validation->validator('apply');
// Get the data
$this->data->job = $this->job->get_job($id);
if ($this->validation->run()) {
// TODO
} else {
$this->data->partial = 'jobs/apply';
$this->load->view($this->layout, $this->data);
}
}
Validator (I know this is being called, a die() within works perfectly) - this file's parent is MY_Validation, therefore the calls to methods within the Validation class you see here are valid.:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed.');
$rules['name'] = 'trim|required';
$rules['email'] = 'trim|required|valid_email';
$rules['cv'] = 'trim|required';
$rules['resume_v'] = 'callback_check_resume';
$this->set_rules($rules);
$fields['name'] = 'Your name';
$fields['email'] = 'Your email address';
$fields['cv'] = 'Your cover letter';
$fields['resume_v'] = 'Your resume';
$this->set_fields($fields);
$this->set_error_delimiters('<li>', '</li>');
function check_resume($str) {
die('test');
}
Anyone see what I am missing here?