public function set_value($value) {

        if (!empty($value) && !$this->field->isChecked()) {

            if (!$this->running_javascript()) {
                $this->field->check();
                return;
            }

            // Check it if it should be checked and it is not.
            $this->field->click();

            // Trigger the onchange event as triggered when 'checking' the checkbox.
            $this->trigger_on_change();

        } else if (empty($value) && $this->field->isChecked()) {

            if (!$this->running_javascript()) {
                $this->field->uncheck();
                return;
            }

            // Uncheck if it is checked and shouldn't.
            $this->field->click();

            // Trigger the onchange event as triggered when 'checking' the checkbox.
            $this->trigger_on_change();
        }
    }
public function set_value($value) {

        if (!empty($value) && !$this->field->isChecked()) {

            if (!$this->running_javascript()) {
                $this->field->check();
                return;
            }

            // Check it if it should be checked and it is not.
            $this->field->click();

            // Trigger the onchange event as triggered when 'checking' the checkbox.
            $this->trigger_on_change();

        } else if (empty($value) && $this->field->isChecked()) {

            if (!$this->running_javascript()) {
                $this->field->uncheck();
                return;
            }

            // Uncheck if it is checked and shouldn't.
            $this->field->click();

            // Trigger the onchange event as triggered when 'checking' the checkbox.
            $this->trigger_on_change();
        }
    }
public function set_value ( $ value ) { if ( ! empty ( $ value ) && ! $ this -> field -> isChecked ( ) ) { if ( ! $ this -> running_javascript ( ) ) { $ this -> field -> check ( ) ; return ; } // Check it if it should be checked and it is not. $ this -> field -> click ( ) ; // Trigger the onchange event as triggered when 'checking' the checkbox. $ this -> trigger_on_change ( ) ; } else if ( empty ( $ value ) && $ this -> field -> isChecked ( ) ) { if ( ! $ this -> running_javascript ( ) ) { $ this -> field -> uncheck ( ) ; return ; } // Uncheck if it is checked and shouldn't. $ this -> field -> click ( ) ; // Trigger the onchange event as triggered when 'checking' the checkbox. $ this -> trigger_on_change ( ) ; } }
Sets the value of a checkbox.

Anything !empty() is considered checked.

@param string $value
@return void
Sets the value of a checkbox .