/README.markdown

https://bitbucket.org/kindari/codeigniter-autoform/ · Markdown · 57 lines · 36 code · 21 blank · 0 comment · 0 complexity · ee0ed10a9c76834d26ab3a0623e92c55 MD5 · raw file

  1. #Codeigniter Autoform
  2. ##How to use?
  3. 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.
  4. ##Display Methods
  5. 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.
  6. ##Examples
  7. ###Quick form
  8. <?php echo new Autoform('username', 'password');
  9. !(http://kindari.net/autoform/autoform-username-password.png)
  10. ###From database result
  11. <?php
  12. $query = $this->db->where('id',1)->get('profiles');
  13. $result = $query->row();
  14. var_dump($result);
  15. $form = new Autoform($result);
  16. echo $form;
  17. !(http://kindari.net/autoform/autoform-db-result.png)
  18. ##Beyond Guessing
  19. 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?
  20. All examples below will follow $form being assigned from the following code:
  21. <?php
  22. $query = $this->db->where('id',1)->get('profiles');
  23. $result = $query->row();
  24. $form = new Autoform($result);
  25. ###Ignore fields
  26. You can have Autoform ignore fields by calling the ignore method.
  27. <?php $form->ignore('phone');
  28. ###Confirm fields
  29. Need to confirm a password or email address entered? Simple!
  30. <?php $form->confirm('email');
  31. ###Hidden fields
  32. Hidden fields are also easily added. By default, an element named 'id' will be set to hidden.
  33. <?php $form->hidden('city');
  34. ###The result
  35. Combining all three of the above methods we get:
  36. !(http://kindari.net/autoform/autoform-custom.png)