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

[eluser]dinhtrung[/eluser]
[quote author="happydude" date="1261174983"]
Code:
function add(&$form, $data)
    {
        print_r($data['userfile']);
    }
[/quote]

Because before calling your model, Form Gen has merged it into 'upload' index. So try print_r($data['upload']['userfile']) for iupload('userfile') instead.
This is implemented in function _load_model below:
Code:
function _load_model()
    {
        if ($this->_posted && !$this->error_string && count($this->model)) {
                if ($this->_data) $this->model_data['uploads'] = $this->_data;



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

[eluser]Jakebert[/eluser]
Hi all. Does anyone know a good example of how one would
go about doing an edit form (with preset
values from a db) with this library? Can't seem
to get th hang of it. Thanks!


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

[eluser]Mat-Moo[/eluser]
Code:
$data=$this->data_model->get_data();
$this->form
  ->open('abc/xyz')
  ->text('fname','Name', (isset ($data->name) ? $data->name : ""), 'Required')
  ->submit;
Just set a value by taking the data from your database record. I use isset to check, but this may not always be needed, but of course that is up to you and what you are doing.


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

[eluser]macigniter[/eluser]
I just finished the next big version change of the library. There are lots of fixed and new features included in this major upgrade.

The config setting for $break_after was completely substituted by a smart and easy to configure prefix/suffix templating system which I am sure meets everyone's requirements for integrating the library with scripting languages or CSS frameworks.

I also added the support for calling multiple models.

Also, rules can now be pre-defined in the configuration file and can even be wrapped around other rules called later in the hierarchy.

Code:
// this config setting would always wrap 'trim|required' and 'xss_clean' around any other rules supplied with the ->text() method

$config['defaults'] = array(
   'text' => array(
      'rules' => 'trim|required^xss_clean'    // ^ will be substituted with rules defined later in the hierarchy
   )
);

// default rules will be wrapped like this:
// 'trim|required|callback_valid_zip|xss_clean'
$this->form->text('zip', 'Zip Code', 'callback_valid_zip');

Oh and whoever struggled with checkgroups/checkboxes or radiogroups will now finally have the chance to precisely configure the behaviour of these elements regarding label positioning and label attributes (for CSS).

More soon... gotta get some sleep now. Will do some testing tomorrow and then hopefully releasing the next version before christmas!


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

[eluser]groyk[/eluser]
Hi macigniter

I am still new to CI. But I must say that I am extremely impressed with your library. I am looking forward for the next release.

Could it be an idea to integrate this library into the core of CI?

Everyone who haven't tried this library should give it a test run ASAP!!


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

[eluser]macigniter[/eluser]
[quote author="groyk" date="1261396305"]
I am still new to CI. But I must say that I am extremely impressed with your library. I am looking forward for the next release.
[/quote]

Thank you!

[quote author="groyk" date="1261396305"]
Could it be an idea to integrate this library into the core of CI?
[/quote]

Well there's tons of helpers and libraries out there that would be worth to be integrated into CI. But the beauty of CI is that it lets you choose which one you like best and doesn't stipulate that you use one or the other. I personally would love to have a better overview of existing libraries rather than searching this forum or browsing through the (not so well done) Wiki. That'd be a great thing if someone would develop a website that lets developers upload and maintain their CI scripts and extensions in a user-friendly interface. Including some script-specific discussion board and version control. *dreaming*


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

[eluser]hugle[/eluser]
[quote author="macigniter" date="1261419601"]
Well there's tons of helpers and libraries out there that would be worth to be integrated into CI. But the beauty of CI is that it lets you choose which one you like best and doesn't stipulate that you use one or the other. I personally would love to have a better overview of existing libraries rather than searching this forum or browsing through the (not so well done) Wiki. That'd be a great thing if someone would develop a website that lets developers upload and maintain their CI scripts and extensions in a user-friendly interface. Including some script-specific discussion board and version control. *dreaming*[/quote]

Heh, must join this Smile))

That would really be amazing thing.
For example when I started using this lib, I can't do anymore forms with native ci LIBSmile

same applies to other helpers like image_thumg etc... which created image thumb if it does not exist.

Maybe someday in the new year of 2010, some group of people will group and do start doing something niceSmile

Anyway, I like this thread became more active etc etc. so more people wil lstart using this libSmile

good luck MacIgniterSmile!


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

[eluser]2think[/eluser]
I'm wondering if anyone else here may have come across a solution to using multiple forms on a backend-type page, you know where we would have someone managing users and page content?

Thanks again and hope to hear from someone if they have any idea how to get multiple forms using this lib on the same page. It could be just my own lack of knowledge if its easy and just missing something.

Frank, thanks for an awesome library. I saw you're releasing the next version perhaps before Xmas, great news.


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

[eluser]macigniter[/eluser]
[quote author="2think" date="1261450653"]I'm wondering if anyone else here may have come across a solution to using multiple forms on a backend-type page, you know where we would have someone managing users and page content?

Thanks again and hope to hear from someone if they have any idea how to get multiple forms using this lib on the same page. It could be just my own lack of knowledge if its easy and just missing something.
[/quote]

I'm doing this myself already. To use multiple forms on a page simply do:

Code:
$this->load->library('form'); // please make sure to use the latest pre-release version!

// form #1
$this->form
->open()
->...
->submit('Submit', 'form1') // the submit's names MUST be different if multiple forms are used in one controller
->onsuccess(...);

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

// use this method to clear all values
$this->form->flush();

// form #2
$this->form
->open()
->...
->submit('Submit', 'form2')
->onsuccess(...);

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

[quote author="2think" date="1261450653"]
Frank, thanks for an awesome library. I saw you're releasing the next version perhaps before Xmas, great news.[/quote]

Thanks! Wait until you see the update. It'll be awesome! :-)


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

[eluser]hugle[/eluser]
I have done something similar to:

Code:
$this->load->library('form');
$form_one = new $this->form();
$form_one->open('controller/method')
->text('etc'...)
->submit();

$form_two = new $this->form();
$form_two->open('controller/method')
->text('etc'..)
->submit();

$data['form_one_output'] = $form_one->get();
$data['form_one_errors'] = $form_one->errors;

$data['form_two_output'] = $form_two->get();
.....

Probably macigniter's sollutions eats less memorySmile
good luckSmile