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-10-2010

[eluser]Mat-Moo[/eluser]
Hmm, that's a pain.. I thought this new version would be flexible enough for all forms, it is, just not mine Sad Will have to give this some thought!


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

[eluser]macigniter[/eluser]
[quote author="Mat-Moo" date="1265846793"]Hmm, that's a pain.. I thought this new version would be flexible enough for all forms, it is, just not mine Sad Will have to give this some thought![/quote]

I'll also think about it. I'm sure there's a solution for this...


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

[eluser]hugle[/eluser]
[quote author="macigniter" date="1265846852"][quote author="Mat-Moo" date="1265846793"]Hmm, that's a pain.. I thought this new version would be flexible enough for all forms, it is, just not mine Sad Will have to give this some thought![/quote]

I'll also think about it. I'm sure there's a solution for this...[/quote]

+1 to this feature Smile


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

[eluser]seanloving[/eluser]
When I set the label position to 'after' then the required_flag appears twice (for example name** instead of name* )

what have I done?

Trying to debug... I loaded the FGL demo app, but my new WAMP system with PHP 5.3 throws these new errors:

Quote:Assigning the return value of new by reference is deprecated
and
Function set_magic_quotes_runtime() is deprecated

Thanks in advance to anyone who knows how to correct for this unexpected ** behavior.

--Sean Loving


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

[eluser]hugle[/eluser]
[quote author="seanloving" date="1266534567"]When I set the label position to 'after' then the required_flag appears twice (for example name** instead of name* )

what have I done?

Trying to debug... I loaded the FGL demo app, but my new WAMP system with PHP 5.3 throws these new errors:

Quote:Assigning the return value of new by reference is deprecated
and
Function set_magic_quotes_runtime() is deprecated

Thanks in advance to anyone who knows how to correct for this unexpected ** behavior.

--Sean Loving[/quote]


Hello,

can you try this?
changde index.php (~8 line or smth) to this:
error_reporting(E_ALL | E_DEPRECATED);

post back the resultsSmile


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

[eluser]Maglok[/eluser]
Have been working with this for a while now, really getting the hang of it. Really usefull library.

It is a shame the user_guide isn't finished since I'd love to know a bit more about the onSuccess() method.

At the moment it looks to me to not really be doing anything so instead of onSuccess I just throw a redirect to a page in the IF that says the form is valid.


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

[eluser]seanloving[/eluser]
[quote author="hugle" date="1266549363"]
Hello,

can you try this?
changde index.php (~8 line or smth) to this:
error_reporting(E_ALL | E_DEPRECATED);

post back the resultsSmile[/quote]

Of course I can surpress PHP errors. But my question / misunderstanding remains about this:

THE LABEL DOES NOT MOVE when I change the label postition to 'after'.

The only thing that happens is that the single * becomes a double **. However, the double asterisked label remains in the 'before' position.

Would someone please try to change the label position to 'after'. Does the label move? Does the double asterisk appear? If this is expected I wonder why. Thanks.

-SL


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

[eluser]macigniter[/eluser]
[quote author="seanloving" date="1266613031"]
THE LABEL DOES NOT MOVE when I change the label postition to 'after'.
[/quote]

Of course you also need to update the stylesheet if you want the labels to be floating to the right. Check out the HTML and you will see that the <label>s will indeed be after the &lt;input&gt; element.

[quote author="seanloving" date="1266613031"]
The only thing that happens is that the single * becomes a double **. However, the double asterisked label remains in the 'before' position.
[/quote]

Can you please post a sample snippet of the element you are creating with FGL? There is a bug with double prefixes/suffixes if you use the ->label() method. I am just updating the library and want to make sure there's nothing more to it... so please help me by posting some example. Thanks!

EDIT: Please don't forget to post a snippet of your form.php config file (the part in the $config['defaults'] regarding 'label')


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

[eluser]macigniter[/eluser]
[quote author="Maglok" date="1266604839"]Have been working with this for a while now, really getting the hang of it. Really usefull library.[/quote]

Thanks!

[quote author="Maglok" date="1266604839"]
It is a shame the user_guide isn't finished since I'd love to know a bit more about the onSuccess() method.[/quote]

Feel free to jump in and help where you can :-)

[quote author="Maglok" date="1266604839"]
At the moment it looks to me to not really be doing anything so instead of onSuccess I just throw a redirect to a page in the IF that says the form is valid.[/quote]

The onSuccess() method is actually a remainder of the original MidgetForms library. It permits you to call a function like redirect upon successful validation. If you need to manipulate the data entered you must do that by calling a model() from FGL.

I personally use the IF construct myself and then handle the form data and redirect within the IF clause. Just really depends on your personal preference if you like to handle the data within the model or the controller.


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

[eluser]seanloving[/eluser]
[quote author="macigniter" date="1266615966"][quote author="seanloving" date="1266613031"]
THE LABEL DOES NOT MOVE when I change the label postition to 'after'.
[/quote]

Of course you also need to update the stylesheet if you want the labels to be floating to the right. Check out the HTML and you will see that the <label>s will indeed be after the &lt;input&gt; element.

[quote author="seanloving" date="1266613031"]
The only thing that happens is that the single * becomes a double **. However, the double asterisked label remains in the 'before' position.
[/quote]

Can you please post a sample snippet of the element you are creating with FGL? There is a bug with double prefixes/suffixes if you use the ->label() method. I am just updating the library and want to make sure there's nothing more to it... so please help me by posting some example. Thanks!

EDIT: Please don't forget to post a snippet of your form.php config file (the part in the $config['defaults'] regarding 'label')[/quote]

EXAMPLE 1
I attached a screenshot of what your demo form looks like when I make two small changes to the default settings of the config file:
Code:
$config['defaults'] = array(
    'label' => array(  
        'position' => 'after',
        'class' => 'right',
        'required_class' => 'required',
        'required_flag' => '*'
    ),

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?

EXAMPLE 2
here is the config/form.php snippet:
Code:
$config['defaults'] = array(
    'label' => array(                                        // all label configuration is done here now!!
        'position' => 'before',
        'class' => 'right',
        'required_class' => 'required',
        'required_flag' => '*'
    ),
I was following a previous example you gave about how to use the ->col() method. Here is my entire form:

Code:
$this->form->open('contacts/'.$action)
                ->hidden('contact_id', $this->input->post('contact_id'))
                ->fieldset( ($action=='add') ? 'Add New Contact' : 'Edit Contact Details' )
                ->col(150, 'left', 'right')
                ->label('First/Last Name', 'name')
                ->label('Street', 'address-1')
                ->label('City/State/Zip', 'state' )
                //->label('Country', 'country' )
                ->label('Telephone', 'telephone' )
                ->label('Email', 'country' )
                ->label('Notes', 'notes' )
                ->col()
                ->text('firstname', '', 'required|trim|max_length[50]', $this->input->post('firstname'), array('element_suffix'=>'','class'=>'combine','style'=>'width:100px'))
                ->margin(20)
                ->text('lastname', '', 'required|trim|max_length[50]',  $this->input->post('lastname'), array('class'=>'combine','style'=>'width:100px'))
                ->margin(4)
                ->text('address1', '', 'required|trim|max_length[50]', $this->input->post('address1'), array('style'=>'width:217px'))
                ->margin(20)
                ->text('city', '', 'required|trim|max_length[40]', $this->input->post('city'), array('element_suffix'=>'','class'=>'combine','style'=>'width:100px'))
                ->margin(20)
                ->text('state', '', 'required|trim|max_length[2]', $this->input->post('state'), array('element_suffix'=>'','class'=>'combine','style'=>'width:23px'))
                ->margin(14)
                ->text('zipcode', '', 'required|trim|max_length[5]', $this->input->post('zipcode'), array('style'=>'width:40px'))
                ->margin(12)
                ->hidden('country', 'USA')
                ->margin(20)
                ->text('telephone', '', 'required|trim|max_length[10]', $this->input->post('telephone'), array('style'=>'width:75px'))
                ->margin(20)
                ->text('email', '', 'required|trim|max_length[50]', $this->input->post('email'), array('style'=>'width:217px'))
                ->margin(20)
                ->text('notes', '', 'trim|max_length[250]', $this->input->post('notes'), array('style'=>'width:217px'))
                ->margin(20)
                ->submit( ($action=='add') ? 'Add Contact': 'Update this Contact', $action )
                ->margin(20)
                ->model('contacts_model', $action.'_contact') // writes to database if valid, otherwise sets a form submission error
                ->validate();

When I change position to 'after' then all the required fields get a double asterisk.

I want to generate the same form WITHOUT using the ->label(). Please confirm that should be possible and easy.

Thanks