Welcome Guest, Not a member yet? Register   Sign In
Editing form and strange behaviour
#1

[eluser]dandys997[/eluser]
Hi again!
I decided to give my application's user an opportunity to edit their profiles. At first - suitable model method returns user data to fill all fields with. Then, in the controller, there's a code:

Code:
$this->form_validation->set_rules("nazwa", "required");
              
if($this->form_validation->run()==FALSE)
{
       $dane=$this->Uzytkownik->dane($id);
       $data=array("tytul" => "Edytuj użytkownika", "dane" => $dane, "id" => $id);
       $this->load->view("panel_edytuj_uzytkownika", $data);
}
I use this data in a view:

Code:
echo form_open_multipart("panel/edytuj_uzytkownika/" . $id);

$this->table->add_row("Nazwa:", form_input("nazwa", set_value("nazwa", $dane->nazwa)));
$image_properties = array("src" => $dane->avatar, "width" => "64", "height" => "64");
$this->table->add_row("Avatar:", img($image_properties));
$this->table->add_row("Zmień avatar:", form_upload("userfile", set_value("userfile")));

echo $this->table->generate();

echo form_submit("submit", "Zmień");
    
echo form_close();

When I invoke above controller method, I successfully get a form with the data filled in "nazwa" field. But when I clear this field and try to post it empty, there's no errors from form_validation class, despite I've set the rule for this field. It behaves like if there weren't any rules or the field was filled correctly - but it isn't.

What's wrong? How to correct it? Thanks in advance for help!
#2

[eluser]Wondering Coder[/eluser]
Add this before the form_open: <?php echo validation_errors(); ?>
#3

[eluser]dandys997[/eluser]
It's not the full code of the view. There's a header with box for validation_errors(), of course.

Validation generally works in the rest part of application, but not there, when I use the second parameter of set_value(), I suppose.




Theme © iAndrew 2016 - Forum software by © MyBB