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 - 09-02-2009

[eluser]macigniter[/eluser]
hey sean,

1. the onkeypress comes from config/form.php
2. what do you mean by "properly"? :-) and when exactly do you add the underscore?
3. you should use "style=width:100px" instead of size, but you can also use "size=100" in the fifth parameter

to 1) see user guide: config file
to 3) see user guide: text element


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

[eluser]echoDreamz[/eluser]
Getting "The upload path does not appear to be valid." when using the upload method. Did I miss someting? BTW kickass library mate!


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

[eluser]nzmike[/eluser]
I've been playing around with library and think it's great! However I'm having a problem calling a model.

I see on the previous page you've suggested something like:

Code:
//Controller
...
->model('auth', 'checklogin')

//Model
function checklogin(&$form, $data) {
    /db stuff
}

This works fine for me but I don't want my models to be tied down to this library in case I decide to change in the future.

Is it possible to have something more abstract like this?

Code:
// Controller
...
->model('auth', 'checklogin', array($username,$password))


// Model
function checklogin($username, $password) {
    //db stuff
}



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

[eluser]macigniter[/eluser]
@echoDreamz: if I remember it right you need to set the absolute path to the upload directory (not the relative)

@nzmike: no, sorry. i guess if you want to use something like that you need to call your model manually within the

Code:
if ($this->form->valid)
{
   // call model here and then add_error(), stop further execution and re-display form
}



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

[eluser]macigniter[/eluser]
Hi Everyone,

I just completed a quick reference guide for the Form Generation Library since I always forget myself which value goes where in the library's methods. I thought you'd appreciate to have one, too. So I am making it available for everyone. Oh and by the way, did I mention that I love small donations? ;-)

Here it is for download:
Form Generation Library Quick Reference


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

[eluser]macigniter[/eluser]
I am working on the next update for the library. Features that will be implemented:

- open() method can be omitted if the form is sent to the current_url()
- fieldset(FALSE) will close the last fieldset added
- new method ->flush() will flush form data (useful if more than one form is generated in the same controller)

I am currently adding support for ->nobr() and other "last accessed" methods in checkgroups and radiogroups. Stay tuned for the next version coming up soon.


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

[eluser]Sixteh[/eluser]
Okay, I'm clearly doing something wrong here.

I've been trying to use this library, and it seems like it could save a lot of time (particularly with recaptcha).

I'm a total noob to CI (started tinkering with it yesterday), rusty with my PHP, and probably a little retarded.

I have the following code in my controller (site.php):
Code:
function contact()
    {
        $content['navigation'] = $this->site_model->navigation(); // Loads a function in site_model that generates navigation as a list
        $content['main_content'] = 'contact'; // Tells includes/template which file to use for content
        
        $this->load->library('form'); // first of all we have to load the library
        
        $this->form // then we fill the form with elements
        ->open('contact')
        ->text('name', 'Your Name', 'trim|alpha_numeric|max_length[30]', 'Your Name')
        ->text('email', 'Your Email Address', 'trim|alpha_numeric|max_length[50]|callback_valid_email', 'Your Email')
        ->text('subject', 'Subject', 'trim|alpha_numeric|max_length[30]', 'Subject')
        ->textarea('message', 'Your Message', 'trim|alpha_numeric|max_length[5000]', 'Your Message')
        ->recaptcha('Are you human?')
        ->submit()
        ->onsuccess('redirect', 'site/sent');
        
        $content['form'] = $this->form->get(); // this returns the validated form as a string
        $content['errors'] = $this->form->errors;  // this returns validation errors as a string
        
        $this->load->view('includes/template', $content);    
    }
    
    function sent()
    {
        echo "Great success!";
    }

And includes/template references views/contact, which is:
Code:
<div id="contact_form">
    <h1>Contact Me</h1>
    &lt;?=$errors?&gt;
    &lt;?=$form?&gt;
</div>

Should be simple, right? I haven't even gotten to the part where it actually sends the email itself...

Except submitting, even without a valid email, just refreshes the page without returning an error message. I have my recaptcha keys in the config file, but leaving that space blank doesn't return any error messages. When I fill it in properly, it just refreshes instead of sending me to site/sent.

What am I doing wrong? D:


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

[eluser]echoDreamz[/eluser]
@macigniter where am I setting the full path for the uploads?


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

[eluser]emorling[/eluser]
I have one controller called editor, which will accept a model with an underlying db table.

The editor has the following methods:
view($model)
edit($model) // detects insert, and update
delete($model)

To accomplish this I want the model to supply the form like this:

$this->form->model('user', 'get_form_fields');

What do you think about that? Good idea? Bad design?


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

[eluser]emorling[/eluser]
Ok, I guess the method didn't work as I had anticipated...

I see now that it is called after the form is submitted, and therefore can't be used to build the form.

In this case I would have preferred to have a huge array defined in the model, that would be used to popuplate the form. Is this possible? Any other approaches?

Thanks