Skip to content

Instantly share code, notes, and snippets.

View pporlan's full-sized avatar

Pedro Porlan pporlan

  • Click Aplicaciones Informáticas SL
  • Móstoles - Madrid - SPAIN
View GitHub Profile
@pporlan
pporlan / README.md
Last active May 15, 2018 18:56 — forked from mikedfunk/README.md

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');

// set post values to zero for unchecked boxes
fix_unchecked(['is_active', 'is_enabled', 'is_verified']);