Welcome Guest, Not a member yet? Register   Sign In
Checkbox Helper
#1

[eluser]stuffradio[/eluser]
This is just something I came up with quickly. I used it so I don't have to write if statements to see if the value in the database is set to true or not.

Code:
<?php

/**
* Formlib V 0.1
* Author: Carl Wuensche
* Date: June 18, 2008
* Purpose: To allow you to perform options for forms easily.
*/

class Formlib
{



  function Formlib()
  {
    $this->CI =& get_instance();
    $this->CI->load->helper('form');
  }
  
  /*
   * Checkbox function
   * Usage: $name is the name of the checkbox, $checked is the value in the database.
   * Example: checkbox("Mycheckbox", $query->row); It assumes that you will be using the keyword "true"
   * in the field of the database. You can easily change this.
   */

  function checkbox($name, $checked)
  {
    if ($checked == "true")
    {
      return form_checkbox($name, $checked, True);
    } else {
      return form_checkbox($name, $checked);
    }
  }

}

Thoughts?
#2

[eluser]Chris Newton[/eluser]
Since you've given this a class and are loading other helpers, technically it's a library, not a helper. Good idea anyway though. I'll be trying this out.

http://ellislab.com/codeigniter/user-gui...lpers.html
#3

[eluser]stuffradio[/eluser]
Well you're wrong because I actually made it as a library myself, but I called it a "helper" only because it helps you with something. I should've said library though Wink

Note: It said Formlib which stands for Form library
#4

[eluser]Chris Newton[/eluser]
I apologize for belaboring a point: regardless of your naming conventions, the post title says "Checkbox Helper" which as you confirm is a misnomer. I'm not incorrect at all, the title is. I only point it out because there are many many new users unfamiliar with the structure of CI that from time to time become confused with the basics, let alone when implementing additional libraries, helper, and plugins.




Theme © iAndrew 2016 - Forum software by © MyBB