-
-
Save pporlan/8316087 to your computer and use it in GitHub Desktop.
Revisions
-
pporlan revised this gist
May 15, 2018 . 1 changed file with 6 additions and 9 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,15 +14,12 @@ * string or as an array. * @return void */ function fix_unchecked($name) { $CI = & get_instance(); if ($CI->input->post()) { if (!is_array($name)) { $name = array($name); } foreach ($name as $item) { if (!$CI->input->post($item)) { $_POST[$item] = 0; } } } } -
pporlan revised this gist
Jan 8, 2014 . 2 changed files with 30 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * @author Mike Funk * @modified_by Pedro Porlan * @email [email protected] * @file checkbox_helper.php */ /** * checkbox value fixer. If a checkbox is not checked, sets it's value * to zero. * @param mixed $name the checkbox form field name. Can be passed as a * string or as an array. * @return void */ function fix_unchecked($name) { function fix_unchecked($name) { $CI = & get_instance(); if ($CI->input->post()) { if (!is_array($name)) { $name = array($name); } foreach ($name as $item) { if (!$CI->input->post($item)) { $_POST[$item] = 0; } } } } } /* End of file checkbox_helper.php */ /* Location: ./application/helpers/checkbox_helper.php */ -
mikedfunk revised this gist
Nov 2, 2012 . 2 changed files with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,4 @@ Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's va $this->load->helper('checkbox'); // set post values to zero for unchecked boxes fix_unchecked(['is_active', 'is_enabled', 'is_verified']); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,7 +14,7 @@ * string or as an array. * @return void */ function fix_unchecked($name) { if (!is_array($name)) {$name = array($name);} foreach ($name as $item) -
mikedfunk revised this gist
Nov 2, 2012 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,4 +7,4 @@ Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's va $this->load->helper('checkbox'); // set post values to zero for unchecked boxes cb(['is_active', 'is_enabled', 'is_verified']); -
mikedfunk revised this gist
Nov 2, 2012 . 1 changed file with 1 addition and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,8 +6,5 @@ Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's va $this->load->helper('checkbox'); // set post values to zero for unchecked boxes cb(array('is_active', 'is_enabled', 'is_verified')); -
mikedfunk revised this gist
Nov 2, 2012 . 1 changed file with 11 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,13 @@ # Checkbox Helper Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's value does not get sent in the form values. Instead of telling CodeIgniter you want to set this value to 0, it says "don't change it." This fixes that, one by one, by setting the value of the associated $_POST array item to zero. You can also pass in an array of checkbox names and it will do each one. ## Usage $this->load->helper('checkbox'); // checkbox names $checkboxes = array('is_active', 'is_enabled', 'is_verified'); // set post values to zero for unchecked boxes cb($checkboxes); -
mikedfunk created this gist
Nov 2, 2012 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # Checkbox Helper Just a tiny helper to help with checkboxes. When you uncheck a checkbox, it's value does not get sent in the form values. Instead of telling CodeIgniter you want to set this value to 0, it says "don't change it." This fixes that, one by one, by setting the value of the associated $_POST array item to zero. You can also pass in an array of checkbox names and it will do each one. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /** * @author Mike Funk * @link http://mikefunk.com * @email [email protected] * @file checkbox.php */ /** * checkbox value fixer. If a checkbox is not checked, sets it's value * to zero. * @param mixed $name the checkbox form field name. Can be passed as a * string or as an array. * @return void */ function cb($name) { if (!is_array($name)) {$name = array($name);} foreach ($name as $item) { if (!$this->input->post($item)) {$_POST[$item] = 0;} } } /* End of file checkbox.php */ /* Location: ./application/helpers/checkbox.php */