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-17-2009

[eluser]Muser[/eluser]
Hi all,

I think this library it is very interesting, but is it possible to manage the form field positions on the view file?

Or at this moment the only layout is to attach one field another one?

I would be able to manage where to render the form field in the view.

Is it possible??

Thank you!


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

[eluser]groyk[/eluser]
[quote author="Muser" date="1253185287"]Hi all,

I think this library it is very interesting, but is it possible to manage the form field positions on the view file?

Or at this moment the only layout is to attach one field another one?

I would be able to manage where to render the form field in the view.

Is it possible??

Thank you![/quote]

Hi Muser

I don't think you can handle the layout in your view. However you can use the
Code:
html()
element to create your design in the controller.


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

[eluser]macigniter[/eluser]
[quote author="Muser" date="1253185287"]
I think this library it is very interesting, but is it possible to manage the form field positions on the view file?

Or at this moment the only layout is to attach one field another one?

I would be able to manage where to render the form field in the view.

Is it possible??[/quote]

Hey there, it actually is. Just use the method

Code:
$this->form
->text('username', 'Username')
->password('pass', 'Password')
->submit();

// ... validation and stuff

$data['form'] = $this->form->get_array();

which allows you to do this in the view file (and feel free to place these tags wherever you want):

Code:
<form action="<?=$form['action']?>" method="post">
<input type="text" name="username" value="<?=$form['username']?>" /><?=$form['username_error']?>
<input type="password" name="password" value="<?=$form['pass']?>" /><?=$form['pass_error']?>
<input type="submit" value="submit">
</form>

It's a little double coding, but you could do it like this. The get_array() methods returns all values as an array where the keys are the element's names.

Also there are some special keys which are:

Code:
'form_open' returns the whole <form> opening tag
'form_close' returns the closing tag
'action' returns the action
'methdos' returns the method

This method is just there if you need to highly customize your form layout in a view file rather than outputting the whole form html via $this->form->get();

Hope that helps...


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

[eluser]macigniter[/eluser]
BTW... anyone still interested in helping to complete the user guide? I am just too busy at the moment but nevertheless would love the guide to be complete. So if you are using the library for a while now and feel confident enought to contribute your help will be greatly appreciated!


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

[eluser]groyk[/eluser]
$_POST data onsuccess()

Thank you for this exceptional library

However I need a small function

when I do the

Code:
->onsuccess('redirect', 'users/edit')

I need to sent $_post data to users/edit

I think it could be done like this

Code:
->onsuccess('redirect', 'users/edit','rules',TRUE)

Is that possible with a small update?


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

[eluser]macigniter[/eluser]
@groyk
I don't think that's possible since you cannot pass variables with the redirect() function.


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

[eluser]groyk[/eluser]
[quote author="macigniter" date="1253285039"]@groyk
I don't think that's possible since you cannot pass variables with the redirect() function.[/quote]

Ok I see, then it needs sessions, db or something for this solution. Not good :-(

Is there any other way? the way the library is builded?


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

[eluser]groyk[/eluser]
Hi

How do I make an text input disabled?

Code:
text()



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

[eluser]groyk[/eluser]
[quote author="groyk" date="1253639769"]Hi

How do I make an text input disabled?

Code:
text()
[/quote]

Simpel!! disabled="true"


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

[eluser]seanloving[/eluser]
@groyk, maybe you can copy the posted data from inside the users/edit function??

Quote:@groyk wrote...

when I do the
->onsuccess('redirect', 'users/edit')

I need to sent $_post data to users/edit

If it is not practical to process data inside the 'users/edit' controller, or if you have more complex processing requirements, then you can first redirect to a processing controller; for example you could call it 'users/processor' and use it like this

Quote:->onsuccess('redirect', 'users/processor')

Then inside your 'users/processors' controller you can do stuff like this:

1. Copy the posted data into variables for easy processing.
2. Process the data
3. Redirect to 'users/edit' or 'users/other', etc...

--Sean Loving