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 - 07-18-2009

[eluser][x26]VOLAND[/eluser]
Quote:I cannot reproduce the problem with the double submit field.
Here is the code:
Code:
$this->load->library('form');
$this->form
->open('auth')
->text('username', lang('auth_page_name_field'), 'trim|required')
->pass('password', lang('auth_page_pwd_field'), 'trim|required')
->hidden('submit', 'xyz123huikj')
->br()
->submit(lang('auth_page_btn_name'));
It happens because hidden field has name `submit`.


And let me give you an advice...
I think all elements must be separated from each other...
If I write the class I would do it this way:
Each element (button, text field, etc) has a corresponding class (Button, Text, ...).
For example, when creating a button by calling button(), new `Button` object is being instantiated and put into the storage (eg.: class field Form::$__elements). And when the complete form has to be received, it's html code is being compiled from the created elements.

Example of the button class:

Code:
class Button {

    private $__label; // An object of type `Label`. Contains a label corresponding to this element

    private $__attr = array(); // Attributes of the tag
    
    function __construct($attr) {
        $this->__attr = $attr;
    }
    
    function __toString() {
        // Build a complete html tag + it's label and return it as a string
    }

    function setLabel(Label $label) {
        $this->__label = $label;
    }
    ...
    // some more code...
    ...

}

It would be very great if you do it this way... Elements duplication would be simply impossible in this case.
All elements' classes should be located in a single file (in order to avoid work slowdown).

And can you make html tags in a form separated by `newline` (\n).
P.S.: sorry for my poor English..


Form Generation Library - El Forum - 07-19-2009

[eluser]macigniter[/eluser]
[quote author="[x26]VOLAND" date="1247940731"]
It happens because hidden field has name `submit`.
[/quote]

it seems like you already found the reason :-) actually this is also in the user guide (which I apologize is not finished yet, but I am working on it)

'submit' is a reserved word if the name attribute is omitted in the submit() element. please take a look at the user guide.


Form Generation Library - El Forum - 07-21-2009

[eluser][x26]VOLAND[/eluser]
Can you include the user guide to the download package?


Form Generation Library - El Forum - 07-23-2009

[eluser]macigniter[/eluser]
Sure. I will provide two downloads next time. One with the user guide and CI install and one without. Just the lib. Btw... I am making some more progress in adding new pages to the user guide...


Form Generation Library - El Forum - 07-24-2009

[eluser]sideshowbob[/eluser]
Hi Macigniter,

Firstly, thanks for this awesome library, I think you will help a lot of people.

Also, where is the "donate" button on your website? I'd love to buy you a coffee/beer as thanks.

I am using your library on a client project of mine and I have a question about checkboxgroup. I am trying to create the below code but I don't think it's possible as there is no way to wrap each checkbox with extra html.

Code:
<ul>
    <li>&lt;input type="checkbox" name="array1[]" value="1" class="check" id="e9aa0"  /&gt;&lt;label for="e9aa0" class="left check">Subcategory 1.1</label></li>
    <li>&lt;input type="checkbox" name="array1[]" value="2" class="check" id="b1653"  /&gt;&lt;label for="b1653" class="left check">Subcategory 1.2</label></li>
    <li>&lt;input type="checkbox" name="array1[]" value="10" class="check" id="ee526"  /&gt;&lt;label for="ee526" class="left check">Subcategory 1.3</label></li>
    <li>etc...</li>
</ul>

I can kind of achieve the layout I need using CSS but it's not ideal and doesn't help non CSS clients.

Any thoughts on a better way?

Cheers,
Bob


Form Generation Library - El Forum - 07-24-2009

[eluser]macigniter[/eluser]
hi bob!

i am glad you like the library. maybe i should think about adding a donation button to the website Wink

anyway, many people requested a way to wrap elements with code and I will definitely add something to easily do that in one of the next versions. i do not know though when that will be. top priority right now is clean the code, finish the user guide and then make further improvements.

i am right now working on finishing the user guide, so hopefully an update to the library will be available very soon!


Form Generation Library - El Forum - 07-24-2009

[eluser]macigniter[/eluser]
@everyone

I just updated my first post to keep everyone updated on the latest releases and important changes. This way you don't have to search the whole thread.

IMPORTANT: everyone who recently updated to version 0.1.3 should update to 0.1.4 to fix a bug when using the "nameasid" functionality. Thanks to Dave I could fix this instantly.


Form Generation Library - El Forum - 08-02-2009

[eluser]Yash[/eluser]
looks really nice.. let me try it.


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

[eluser]pysco68[/eluser]
Hello out there Wink

I just started using your Library, and.... well just "WOW!". There's just one thing I'm missing (more than the full doc Wink: is it possible to create "confirmation" fields. I mean like in the CI validation class "match[somefield]"

Greetings from France


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

[eluser]macigniter[/eluser]
[quote author="pysco68" date="1249487148"]Hello out there Wink

I just started using your Library, and.... well just "WOW!". There's just one thing I'm missing (more than the full doc Wink: is it possible to create "confirmation" fields. I mean like in the CI validation class "match[somefield]"

Greetings from France[/quote]

No problem. Just do it like this:

Code:
$this->form
->password('pass', 'Password', 'required')
->password('pass2', 'Repeat Password', 'required|matches[pass]')