File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.select.php
<?php
/**
* This file contains the iwp_field_select class
*
* @version $Id$
*
*
* @package IWP
* @subpackage IWP_FormFields
*/
/**
* Select Field Class
* This class is used by the api form class to generate a select box list (not multiple) field.
*
* @package IWP
* @subpackage IWP_FormFields
*/
class iwp_field_select extends iwp_field {
/**
* This is the form field type of the field
*
* @var string
*/
public $type = 'select';
protected $showLabel = false;
/**
* __construct
* The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
*
* @var string
*/
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
*/
function GetFieldOutput($setOnly=false){
$this->SetAttribute('style','margin-right:5px;' . $this->GetAttribute('style'));
$inputField = $this->Prepend.'<select id="'. iwp_htmlspecialchars($this->FieldName) .'" name="'. iwp_htmlspecialchars($this->FieldName) .'" ';
$inputField .= $this->GetAttributes();
$inputField .= '>';
if(is_array($this->FieldOptions)){
foreach($this->FieldOptions as $k=>$v){
$inputField .= '<option value="'. iwp_htmlspecialchars($k) .'" ';
if(is_array($this->FieldValue)){
if(in_array($k, $this->FieldValue)){
$inputField .= ' selected';
}
}else{
if($this->FieldValue == $k){
$inputField .= ' selected';
}
}
$valueHTML = iwp_htmlspecialchars($v);
// special case for selects, allow repeated spaces at the beginning of items to be treated as indentation
$valueHTML = preg_replace('#^(\s{2,})#e', 'str_repeat(" ", strlen("$1"))', $valueHTML);
$inputField .= '>'. $valueHTML .'</option>';
}
}
$inputField .= '</select>'.$this->Append;
parent::GetFieldOutput();
$this->template->Assign('inputField', $inputField);
$this->template->Assign('showLabel', false);
$this->template->Assign('FieldName', $this->FieldName);
if(!$setOnly){
return $this->template->ParseTemplate('form.field', true);
}
return '';
}
/**
* Validate
* This is the function that data for this field is passed to to ensure it was submitted properly.
*
* @return string|boolean If the data is not valid, it will return false, if it is valid it will return a value
*/
function Validate($arrData){
return $arrData[$this->FieldName];
}
}