[eluser]Leftfield[/eluser]
Everybody Hello!
I did not clear the problem with the Update method, my simle method UPDATE does not work,and i have some problems with pass $id var into my update method , plz i need help of CI guru, thats my code:
Controller
Code:
function pageedit($id) {
$this->load->library('common_lib');
$this->common_lib->auth();
$this->load->helper(array('form', 'url'));
$this->load->library('validation');
$this->validation->set_rules('textfield', 'textfield', 'required');
$this->validation->set_rules('textarea', 'textarea', 'required');
//читаем запись из БД
if (!$this->input->post('textfield') && !$this->input->post('textarea')) {
$item = $this->Kernel->get($id);
$this->validation->textfield = $item['title'];
$this->validation->textarea = $item['fulltext'];
}
$data = array();
$CI = &get;_instance();
$title = $CI->config->item('admin_title');
$author = $CI->config->item('admin_login');
$data['title'] = $title;
if ($this->validation->run() == FALSE) {
$this->load->view('admin/editpage', $data);
}
else {
$data = array(
'title' => $this->input->post('textfield'),
'fulltext' => $this->input->post('textarea'),
'date' => date('Y:m:d')
);
$this->Kernel->update($data, $id);
redirect('/admin/browsepages/');
}
}
Model
Code:
function update($data, $id) {
$this->db->where('id', $id);
$this->db->update('stand_alone_pages',$data);
}
View (Form)
Code:
<form id="form1" name="form1" method="post" action="/admin/pageedit/">
<p>
<input name="textfield" type="text" value="<?php echo form_prep(@$this->validation->textfield)?>" size="60" />
</p>
<p>
<textarea name="textarea"><?php echo form_prep(@$this->validation->textarea)?></textarea>
</p>
<p>
<input type="submit" name="Submit" value="Редактировать" />
</p>
</form>
Here is what I get
Quote:A PHP Error was encountered
Severity: Warning
Message: Missing argument 1 for Admin::pageedit()
Filename: controllers/admin.php
Line Number: 95
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: id
Filename: controllers/admin.php
Line Number: 128
A PHP Error was encountered
Severity: Warning
Message: Cannot modify header information - headers already sent by (output started at Z:\home\codecms\www\system\libraries\Exceptions.php:166)
Filename: helpers/url_helper.php
Line Number: 541
What am I doing wrong, tell me please ?