/** * Check if a checkable is checked * * @return boolean Checked or not */ protected function isChecked($name = null, $value = null) { if (!$name) { $name = $this->name; } // If it's a checkbox, see if we marqued that one as checked in the array // Or if it's a single radio, simply see if we called check if ($this->isCheckbox() or !$this->isCheckbox() and !$this->items) { $checked = array_get($this->checked, $name, false); } else { $checked = array_get($this->checked, $value, false); } // Check the values and POST array $post = Former::getPost($name); $static = Former::getValue($name); $manual = $checked; if (!is_null($post) and $post !== Config::get('unchecked_value')) { $isChecked = $post == $value; } elseif (!is_null($static)) { $isChecked = $static == $value; } else { $isChecked = $checked; } return $isChecked ? true : false; }
/** * Use values stored in Former to populate the current field */ private function repopulate() { $value = Former::getValue($this->name); // If nothing found, replace by fallback if (!$value) { $value = $this->value; } // Overwrite value by POST if present $value = Former::getPost($this->name, $value); $this->value = $value; }