im new on codeigniter and try to resolve following problem for hours now. I try to set_value in a form but when i set it i get following error:
A PHP Error was encountered Severity: Error Message: Call to undefined function set_value() Filename: modals/register_modal.php Line Number: 27 Backtrace:
When i delete set_value() on line 27, everything works fine.
Line number 27 is the set_value() line:
<div class="row">
<div class="form-group">
<label class="control-label sr-only">Vorname:</label>
<div class="col-md-8 col-md-offset-2 col-xs-10 col-xs-offset-1">
<input type="text" class="form-control" name="firstname" placeholder="Vorname" value="<?php echo set_value('firstname'); ?>" size="50" />
<i class="fa form-control-feedback" aria-hidden="true"></i>
</div>
</div>
</div>
Thats my controller:
class Form extends CI_Controller {
public function index()
{
$this->load->helper('form');
$this->load->library('form_validation');
$this->form_validation->set_rules('firstname', 'Vorname', 'required|callback_username_check');
$this->form_validation->set_rules('surename', 'Nachname', 'required');
$this->form_validation->set_rules('email', 'Email', 'required');
$this->form_validation->set_rules('password', 'Passwort', 'required');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('modals/register_modal');
}
else
{
$this->load->view('modals/login_modal');
}
}
public function username_check($str)
{
if ($str == 'test')
{
$this->form_validation->set_message('username_check', 'The {field} field can not be the word "test"');
return FALSE;
}
else
{
return TRUE;
}
}
}
I also set Auto-Load:
$autoload['helper'] = array('form');