CodeIgniter Forums
form generation library - how to display success message? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: form generation library - how to display success message? (/thread-51870.html)



form generation library - how to display success message? - El Forum - 05-21-2012

[eluser]Unknown[/eluser]
Hi,

I'm using form generation library to create forms.
Everyting is fine except one thing.

I have a form:
Code:
$this->form
    ->hidden('module', 0)
    ->hidden('join_lang', 'pl')
    ->text('join_name', 'Nazwa kategorii', 'required|trim|xss_clean')
    ->text('join_link', 'Slug', 'required|trim|xss_clean')
    ->select('id_parent', $select_cat, 'Rodzic')
    ->text('ordr', 'Kolejność', 'numeric|trim|xss_clean')
    ->textarea('join_text', 'Opis', 'trim|xss_clean')
    ->textarea('join_meta_title', 'Meta title', 'trim|xss_clean')
    ->textarea('join_meta_keywords', 'Meta keywords', 'trim|xss_clean')
    ->textarea('join_meta_description', 'Meta description', 'trim|xss_clean')
    ->model('Category', 'add_new')
    ->submit('Dodaj kategorię')
    ->onsuccess('redirect', 'categories');

$data['category_add_form'] = $this->form->get();
$data['errors'] = $this->form->errors;

$this->load->view('test', $data);

Now onsuccess its redirect to the categories page, but what I would like is to
not to redirect, stay on the same page and display success message above the form
(something like errors but for example in green color).

My question is how to do this?

thanks!


form generation library - how to display success message? - El Forum - 05-21-2012

[eluser]CroNiX[/eluser]
You can use session flashdata to store a message when validation passes and in your view check to see if it exists and if it does, display it.


form generation library - how to display success message? - El Forum - 05-21-2012

[eluser]Unknown[/eluser]
Works perfect!
Many thanks.