HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.checkbox.php
<?php

/**
 * This file contains the iwp_field_checkbox class
 *
 * @version $Id$
 * 
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

/**
 * Checkbox Field Class
 * This class is used by the api form class to generate a checkbox form field.
 *
 * @package IWP
 * @subpackage IWP_FormFields
 */

class iwp_field_checkbox extends iwp_field {
	/**
	 * This is the form field type of the field
	 *
	 * @var string
	 */
	public $type = 'checkbox';

	/**
	 * __construct
	 * The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
	 *
	 * @var string
	 */
	public function __construct($name=null){
		parent::__construct($name);
	}

	/**
	 * GetFieldOutput
	 * Returns the HTML for this field. It generates the relevant parts, assigns them to template variables and returns a parse template file.
	 *
	 * @return string Returns the field HTML
	 */
	public function GetFieldOutput($setOnly=false){
		$inputField = $this->Prepend.'<input type="checkbox" id="'. iwp_htmlspecialchars($this->FieldName) .'" name="'. iwp_htmlspecialchars($this->FieldName) .'" value="checked"';
		if($this->FieldValue == "checked"){
			$inputField .= ' checked="checked"';
		}

		$inputField .= $this->GetAttributes();

		$inputField .= ' />'.$this->Append;

		parent::GetFieldOutput();

		$this->template->Assign('FieldName', $this->FieldName);
		$this->template->Assign('inputField', $inputField);

		if(!$setOnly){
			return $this->template->ParseTemplate('form.field', true);
		}
		return '';
	}

	/**
	 * This is the validation function for this field type. It checks if the submitted data has the item as checked or not.
	 *
	 * @param string $arrData
	 * @return unknown
	 */
	public function Validate($arrData){
		if(!isset($arrData[$this->FieldName])){
			return false;
		}else{
			return 'checked';
		}
	}

	/**
	 * LoadValue
	 * This is takes an array of data and picks of the value for this specific field and stores in in the FieldValue variable
	 *
	 * @return void Doesn't return anything
	 */
	public function LoadValue($arrData){
		if(isset($arrData[$this->FieldName])){
			if($arrData[$this->FieldName] === "checked" || $arrData[$this->FieldName] === "1" || $arrData[$this->FieldName] === "on"){
				$this->FieldValue = "checked";
			} else {
				$this->FieldValue = "";
			}
		}
	}
}