CodeIgniter Forums
Form Generation Library - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22)
+--- Thread: Form Generation Library (/showthread.php?tid=16439)



Form Generation Library - El Forum - 04-26-2009

[eluser]macigniter[/eluser]
Hi Gregor,

I think all of your questions are more related to JavaScript than the form generation library. Please check the tinyMCE documentation on how to integrate it with a form. For the date picker you can use any of the jQuery scripts for example.


Form Generation Library - El Forum - 04-27-2009

[eluser]abmcr[/eluser]
I have not understand how this lines
Code:
->model('example', 'do_db_stuff')

        // do a redirect
        ->onsuccess('redirect', 'welcome/success');
        
        /*
         * write the validated form to the $data array
         *
         * NOTE: instead of getting the entire form at
         * once you can also do something like this:
         *
         * $form->validate();
         *
         * if ($form->valid)
         * {
         *        do something
         * }
         *
         * $data['form'] = $form->get();
         */
        $data['form'] = $form->get()

In the model i have not the data_array but only the data of the uploaded files?

The code of model is
Code:
function do_db_stuff(&$form, $data)
    {
        // do db stuff after the form was submit and validated
        // $data will contain $data['uploads'] with all the upload data
        var_dump($data);
        var_dump($form);
        die();
    }
and in the $form i get all information aboit form and not only the data submitted


Form Generation Library - El Forum - 04-27-2009

[eluser]Thorpe Obazee[/eluser]
Just checked the documentation. It seems to have 'missing' pages. Although, I don't know how important those pages are.


Form Generation Library - El Forum - 04-27-2009

[eluser]abmcr[/eluser]
Yes the doc is not yet completed....


Form Generation Library - El Forum - 05-05-2009

[eluser]Palino[/eluser]
great work!

this WORKS for me:

Code:
...FORM...
$data['form'] = $form->get(); // this returns the validated form as a string
$data['errors'] = $form->errors;  // this returns validation errors as a string
$this->load->view('order', $data);

but i i have problem if i need write the form using Template library (im using HMVC too):

Code:
$data['form'] = $form->get(); // this returns the validated form as a string
$data['errors'] = $form->errors;  // this returns validation errors as a string
    
$content = $this->load->view('order', $data, TRUE);

$this->template->write('col1',$content);
$this->template->render();

hmm, i just checked log file and i have this error manytimes there:
ERROR - 2009-05-05 13:29:30 --> Severity: Notice --> Undefined property: El::$globals (line 76)

looks like undefined are all variables from the El class Sad

do you see any reason?

thanks

pali


Form Generation Library - El Forum - 05-05-2009

[eluser]shreder[/eluser]
Hey.

Any updates to the user guide or library yet?

Thanks!


Form Generation Library - El Forum - 05-09-2009

[eluser]Robert May[/eluser]
I'm a bit confused as to how to use the validation. I can see how you make the form, but where should I submit it, back to the same function, ie submitting from index.php/auth/login to index.php/auth/login?

I'm confused!

Is it meant to be like this (which I'm not sure would work):

Code:
class Auth extends Controller {

    function Auth()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->session->keep_flashdata('refer');
        $this->load->library('form'); // first of all we have to load the library
        $form = new Form(); // then we instantiate a new form object
        
        $form // and fill it with elements
        ->open('auth/login')
        ->text('author_name', 'Username/email:', 'trim|alpha_numeric|max_length[255]|xss_clean')
        ->pass('author_password', 'Password:', 'trim|alpha_numeric|max_length[20]|xss_clean')
        ->reset()
        ->submit();
        
        $data['form'] = $form->get(); // this returns the validated form as a string
        $data['errors'] = $form->errors;  // this returns validation errors as a string
        
        $content    = $this->load->view('auth', $data, TRUE);
        
        $data        = array(
                            'page_title'    =>    'Login',
                            'sub_heading'    =>    'Please login to continue',
                            'content'        =>    $content,
                        );
        $this->templater->build($data);
    }
    
    function login()
    {
        $data['form'] = $form->get(); // this returns the validated form as a string
        $data['errors'] = $form->errors;  // this returns validation errors as a string
        $form->validate();
        
         if ($form->valid)
         {
                do something
         }



Form Generation Library - El Forum - 05-09-2009

[eluser]shreder[/eluser]
You should submit it to the controller that handles it.
IF it's a login form then submit it to the controller that checks whether a correct/username password was entered.


Form Generation Library - El Forum - 05-10-2009

[eluser]Robert May[/eluser]
Huh? :-S


Form Generation Library - El Forum - 05-11-2009

[eluser]macigniter[/eluser]
@robert:

In order to make it work you need to submit the form to the same controller and then redirect from there. You cannot access $form->get() in the login() function, since you haven't instantiated the form object in that function.

Try this:

Code:
class Auth extends Controller {

    function Auth()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->session->keep_flashdata('refer');
        $this->load->library('form'); // first of all we have to load the library
        $form = new Form(); // then we instantiate a new form object
        
        $form // and fill it with elements
        ->open('auth')
        ->text('author_name', 'Username/email:', 'trim|alpha_numeric|max_length[255]|xss_clean')
        ->pass('author_password', 'Password:', 'trim|alpha_numeric|max_length[20]|xss_clean')
        ->reset()
        ->submit();

        $form->validate();  

        if ($form->valid) redirect('auth/login');

        $data['form'] = $form->get(); // this returns the validated form as a string
        $data['errors'] = $form->errors;  // this returns validation errors as a string
        
        $content    = $this->load->view('auth', $data, TRUE);
        
        $data        = array(
                            'page_title'    =>    'Login',
                            'sub_heading'    =>    'Please login to continue',
                            'content'        =>    $content,
                        );

        $this->templater->build($data);
    }
    
    function login()
    {
        // this is where you put the stuff that is shown when the user has successfully logged-in. don't forget to add an authentication here!
    }