[eluser]Rhaziel[/eluser]
Hello guys,
I have a serious problem that i cant solve for about 6 hours now.
this is the controller function i use:
Code:
public function edit()
{
$this->load->helper('form');
$this->load->library('form_validation');
$data['title'] = 'Bronie w Erpegi DUOS';
$data['type'] = 'weapons';
$data['type_pl'] = 'bron';
$this->form_validation->set_rules('edit_object', 'Nazwa', 'required');
if ($this->form_validation->run() === FALSE)
{
$data['edit_list'] = $this->db_functions_model->get_list($data['type']);
$this->load->view('templates_views/header', $data);
$this->load->view('templates_views/panel');
$this->load->view('kompendium_views/edit', $data);
$this->load->view('templates_views/footer');
}
else
{
$edited_object_name = $this->input->post('edit_object');
$data['type_pl'] = $edited_object_name;
$this->form_validation->set_rules('new_description', 'nowy opis', 'required');
if ($this->form_validation->run() === FALSE)
{
$data['entry_description'] = $this->db_functions_model->get_entry_data($data['type'],$edited_object_name);
$this->load->view('templates_views/header', $data);
$this->load->view('templates_views/panel');
$this->load->view('kompendium_views/edit_data', $data);
$this->load->view('templates_views/footer');
}
else
{
$this->db_functions_model->set_entry_data($data['type'],$edited_object_name);
redirect('weapons/');
}
}
}
And im sure the problem is in the controller. The model works just fine and updates the DB.
Let me show you the two views though:
edit.php:
Code:
<div id="panel"><h2>Zmien: <?=$type_pl?></h2></div>
<?php echo validation_errors(); ?>
<?php echo form_open(''.$type.'/edit') ?>
<table class="tborder">
<tr class="trow2">
<td>
<select name="edit_object">
<?php foreach ($edit_list as $choice): ?>
<option value="<?php echo $choice['name'] ?>">
<?php echo $choice['name'] ?></option>
<?php endforeach ?>
</select>
</td>
</tr>
<tr class="trow2">
<td>
<br /> <br /><br />
</td>
</tr>
<tr class="trow2">
<td>
<input type="submit" name="submit" value="Edytuj <?=$type_pl?>" />
</td>
</tr>
</table>
</form>
and edit_data.php
Code:
<div id="panel"><h2>Edytuj opis: <?=$type_pl?></h2></div>
<?php echo validation_errors(); ?>
<?php echo form_open(''.$type.'/edit_data') ?>
<form>
<table class="tborder">
<tr class="trow2">
<td>
<textarea name="new_description" ><?=$entry_description?></textarea>
</td>
</tr>
<tr class="trow2">
<td>
<br /> <br /><br />
</td>
</tr>
<tr class="trow2">
<td>
<input type="submit" name="submit" value="Zmien <?=$type_pl?>" />
</td>
</tr>
</table>
</form>
so what i get is:
I go to controller/edit
it lets me select an item from the list - everything so far is perfect
i go to next view from there - the edit_data
there i get the textarea filled by info from DB(model works just fine as you can see).
BUT! what i see above the text area is an error from form_evaluation!
Quote:The nowy opis field is required.
so i go ahead and modify the info in textarea, hit the button and get: 404 Page Not Found
This is obviously because i have this in my edit_data.php:
Code:
''.$type.'/edit_data'
which takes me to my controller which does not have this function as it has only edit() function.
SO this is driving me nuts! How can i do this??? I cannot evaluate the form because of this!!