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-30-2011

[eluser]Davide Bellini[/eluser]
You can apply a class on a textarea, like "wysi" and, in your js file, associate this class to a rich text editor script, for example :

$('.wysi'). TinyMCE();


Form Generation Library - El Forum - 05-02-2011

[eluser]leftyboy[/eluser]
Hi

I've been using this Library for a while and it's great, nice and easy to use.

The only thing I need is to be able to use custom callbacks in the validation but I can't see anything in the documentation regarding this? Is it possible to use callbacks with the Form Generation Library?

TIA


Form Generation Library - El Forum - 05-02-2011

[eluser]Maglok[/eluser]
The Form Gen Library hooks into the codeigniter validation class. So exactly the same way.

"required|trim|callback_something"


Form Generation Library - El Forum - 05-02-2011

[eluser]leftyboy[/eluser]
Hi Simon

OK so I can just follow the normal callback procedure and add the callback as the last validation rule?

Thanks for the confirmation.

L


Form Generation Library - El Forum - 05-02-2011

[eluser]Davide Bellini[/eluser]
Yes, follow CI form validation callback.


Form Generation Library - El Forum - 05-03-2011

[eluser]Unknown[/eluser]
Just to save anyone else the problem - if you're using two forms on one page you need to make ALL the form fields are uniquely named. You might get away with it depending on the overlap and your rules but you might also get unintended results.

The reason is the way the library decides if the form has been submitted: it's in this function below.

Code:
function _check_post()
    {
        foreach ($this->_elements as $el)
        {
            if ($el['name'])
            {
                $name    = str_replace('[]', '', $el['name']);

                if (isset($_POST[$name]))
                {
                    $this->_posted = TRUE;
                    break;
                }
            }
        }
    }

Essentially what it's doing is looping through the form elements and checking the post array to see if the element is in there. So you could have two forms with 100 fields each and it'll check items [0] through [99] and if JUST ONE OF THEM is identically named and set it'll believe the form was posted. At which point it kicks off the validations, populates the error fields, etc.

The real danger is if you pass validation anyway - then you'll fire off your various events and potentially take some actions, redirect, etc. I confirmed this by turning off all validation on form 1 and pressing the submit button on form 2. It called my model and inserted a record with all kinds of junk because it was using unpopulated post values.

Simply insuring all your fields are uniquely named (I just put FORM1 or FORM2 in front of all my fields) will prevent the problem though it does mean you can't re-use models unless you cope with that within them.

I'm under deadline or I'd look for a more elegant solution - maybe checking the form name in the validate function where _check_post() gets called?


Form Generation Library - El Forum - 05-08-2011

[eluser]k7faq[/eluser]
I am looking for clarification here...

I see there is a
Code:
$element_suffix
option as a config file option only for text fields.

What I want to do is using this library is create an image to the right of a text input field, for example. This image would contain a ?. When the user hovers/clicks the ? a popup window will provide them with details as to what the field is for, length, format, acceptable characters, et al.

It seems to me the "element_suffix" would be appropriate way to incorporate this feature if I could determine a way to populate in a controlled manner such as:
Code:
element_suffix = '<div id=help_' . $label_id . '></div><br />'
where $label_id is the assigned label id in the form declarations.

Any thoughts on this is appreciated.
Thanks.


Form Generation Library - El Forum - 05-16-2011

[eluser]tieungao[/eluser]
Hi mac,

First thanks for very userful library, then second, i have question need your help.

Maybe this located some where in this thread, but many pages so i decide to ask here.

Have anyway to let error inline appear before the fields, instead of appear after fields like current?


Form Generation Library - El Forum - 05-16-2011

[eluser]k7faq[/eluser]
[quote author="tieungao" date="1305618583"]Hi mac,

Have anyway to let error inline appear before the fields, instead of appear after fields like current?[/quote]

Possibly this page has what you are looking for? http://frankmichel.de/formgenlib/user_guide/general/error_display.html


Form Generation Library - El Forum - 05-16-2011

[eluser]tieungao[/eluser]
Thanks for replying me, but in the link you give me :

If set to TRUE, error messages will be displayed inline after the element.

Problem is im finding the way to add error inline before the element, not after