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 - 02-19-2010

[eluser]seanloving[/eluser]
Is there a way to highlight multiple fields with a single error?
Something like this would be useful:
Code:
$form->add_error( array('street','city','state','zipcode'), 'no such address for this contact' )
Feature request / just an idea.


Form Generation Library - El Forum - 02-19-2010

[eluser]BaRzO[/eluser]
+1 Nice idea...


Form Generation Library - El Forum - 02-22-2010

[eluser]macigniter[/eluser]
[quote author="seanloving" date="1266625891"]Please notice that the position is 'after' but looking at the screenshot you see the labels are 'before'. Where is the CSS that controls this?
[/quote]

The CSS that controls this is located in /styles/form.css (please read the user guide in regards to this).

PLEASE NOTE
In your example you are assigning the CSS class 'right' to all the labels. The CSS class 'right' is actually floating LEFT! It just sets the text-align to 'right'. So clearly that's the reason why the labels are still on the left and not on the right :-)

I just played around and was able to render the example form with labels after within 5 minutes. It is mandatory that you change the CSS since a change in the config file alone doesn't do the trick.

Here is my "label after" example:

1. Modify CSS (added to existing form.css)

Quote:/**
* use this class in the $config['defaults'] for 'label' in the config file
* if you want to display the label after the field
*/
label.after {
float: none;
padding-left: 10px;
vertical-align: top;
text-align: left;
}

label.after.combine {
width: auto;
float: left;
padding: 0;
}

2. Modified Configuration file (form.php)

Code:
$config['defaults'] = array(
    'label' => array(
        'position' => 'after',           // this will generate the <label> tag after the element
        'class' => 'left after',         // this will add these classes to all labels
        'required_class' => 'required',
        'required_flag' => '*'
    )
...

3. Changed some lines in the welcome.php controller

Please grab the modified controller here.

4. Et voila!


Form Generation Library - El Forum - 02-22-2010

[eluser]macigniter[/eluser]
[quote author="seanloving" date="1266657681"]Is there a way to highlight multiple fields with a single error?
Something like this would be useful:
Code:
$form->add_error( array('street','city','state','zipcode'), 'no such address for this contact' )
Feature request / just an idea.[/quote]

I like this idea, too!


Form Generation Library - El Forum - 02-22-2010

[eluser]macigniter[/eluser]
[quote author="seanloving" date="1266625891"]
When I change position to 'after' then all the required fields get a double asterisk.[/quote]

I just uploaded a new version with some minor bugfixes. Please install and let me know if you still get the double asterisks. THANKS!


Form Generation Library - El Forum - 02-22-2010

[eluser]macigniter[/eluser]
@ALL

New Version (1.0.1) posted!

Download from here...
Read change log...


Form Generation Library - El Forum - 02-22-2010

[eluser]Mat-Moo[/eluser]
1.0.1 - 02/18/09 - Last year Smile
(edit: lol even in the source!)


Form Generation Library - El Forum - 02-22-2010

[eluser]macigniter[/eluser]
[quote author="Mat-Moo" date="1266886834"]1.0.1 - 02/18/09 - Last year Smile
(edit: lol even in the source!)[/quote]

ooops Wink never mind... you all know what i mean Big Grin


Form Generation Library - El Forum - 02-22-2010

[eluser]seanloving[/eluser]
@macigniter- I think I now understand the interaction between form.css and config/form.php.
Thank you.

[quote author="macigniter" date="1266884997"][quote author="seanloving" date="1266625891"]
When I change position to 'after' then all the required fields get a double asterisk.[/quote]

I just uploaded a new version with some minor bugfixes. Please install and let me know if you still get the double asterisks. THANKS![/quote]

Yes I still get double asterisks. NOT a priority, NOT a requirement, but FYI.


Form Generation Library - El Forum - 02-23-2010

[eluser]macigniter[/eluser]
[quote author="seanloving" date="1266911394"]
Yes I still get double asterisks. NOT a priority, NOT a requirement, but FYI.[/quote]

Can you please send me your:
- form.php config file
- welcome.php controller
- form.css stylesheet

via email to info [at] frankmichel dot com? I would like to dig deeper and see what causes this double asterisk. Thanks!!