/README.markdown
https://bitbucket.org/kindari/codeigniter-autoform/ · Markdown · 57 lines · 36 code · 21 blank · 0 comment · 0 complexity · ee0ed10a9c76834d26ab3a0623e92c55 MD5 · raw file
- #Codeigniter Autoform
- ##How to use?
- Autoform is for lazy people like me :) It extends the form helper functions and adds auto detection of field type and building the complete form.
- ##Display Methods
- Currently the system outputs a table, but there is support for multiple display methods for when I add others. The table that is built consists of one form label and element per table row.
- ##Examples
- ###Quick form
- <?php echo new Autoform('username', 'password');
- !(http://kindari.net/autoform/autoform-username-password.png)
- ###From database result
- <?php
- $query = $this->db->where('id',1)->get('profiles');
- $result = $query->row();
- var_dump($result);
- $form = new Autoform($result);
- echo $form;
- !(http://kindari.net/autoform/autoform-db-result.png)
- ##Beyond Guessing
- Autoform guesses what it should do with whatever you hand to it. But what if what you hand to it came from a database, and there are somethings in that database you don't want to include in the form? Or if you need to confirm something, like an email or password? or if a value should be hidden, like an id?
- All examples below will follow $form being assigned from the following code:
- <?php
- $query = $this->db->where('id',1)->get('profiles');
- $result = $query->row();
- $form = new Autoform($result);
- ###Ignore fields
- You can have Autoform ignore fields by calling the ignore method.
- <?php $form->ignore('phone');
- ###Confirm fields
- Need to confirm a password or email address entered? Simple!
- <?php $form->confirm('email');
- ###Hidden fields
- Hidden fields are also easily added. By default, an element named 'id' will be set to hidden.
- <?php $form->hidden('city');
- ###The result
- Combining all three of the above methods we get:
- !(http://kindari.net/autoform/autoform-custom.png)