|
|
|
File: C:/usr/local/lib/php/blueshoes-4.2/core/html/form/Bs_FormFieldSelect.class.php
BlueShoes Application Framework - Form
Bs_FormFieldSelect
Bs_Object | +-- Bs_FormElement | +-- Bs_FormField | +-- Bs_FormFieldSelect
SELECT Form Field Class
|
public class Bs_FormFieldSelect extends Bs_FormField
SELECT Form Field Class
example tag:<select name="fieldname" size="5" multiple><option value="1" SELECTED>one</option><option value="2" SELECTED>two</option><option value="3">three</option></select>what's special about this tag?alot is different to a text field for example.- value => the real value can be different from the visible value.- value => multiple values can be selected.- size => how large the select field should be displayed. needs to be >1 for multiple.- multiple => if more then one value can be selected. size needs to be set and >1.- events => does not support the usual 14 events, only 'onBlur', 'onFocus' and 'onChange'(2001/05/01)- all the following object vars are of no use and thus ignored (mainly because the usercannot change the values at all, he can only select them):- bsDataType - mustContain- bsDataInfo - notContain- minLength - mustBeUnique- [maxLength] - regularExpression- mustStartWith - trim- notStartWith - remove- mustEndWith - replace- notEndWith - case- optionsthe options that are selectable for the user.- valueDefaultthe following data structores are allowed:array('1'=>'one', '2'=>'two', '3'=>'three');array('en'=>array('1'=>'one','2'=>'two','3'=>'three'), 'de'=>array('1'=>'eins','2'=>'zwei','3'=>'drei'), 'fr'=>array('1'=>'un','2'=>'deux','3'=>'trois'));while these are not:'one';array('one', 'two', 'three');array('en'=>'one', 'de'=>'eins', 'fr'=>'un');array('en'=>array('one','two','three'), 'de'=>array('eins','zwei','drei'), 'fr'=>array('un','deux','trois'));because it would not be possible to know the difference sometimes.this means: even if you have only one default value, it must be an array. and you alwaysneed key=>val, even if the key and the value is the same.no dependencies here.
| Authors | andrej arn <andrej@arn.li> |
| Version | 4.0.$id$ |
| Copyright | blueshoes.org |
|
| |
|
Direct known subclasses: Bs_FormFieldSelectImage, Bs_DaFormFieldComboBox, Bs_FormFieldChVisa, Bs_FormFieldCountryList
|
|
Methods inherited from Bs_FormField |
| bs_formfield, &getelement, getfield, addenforcecheckbox, isexplodable, getadvancedstyle, getadvancedstylehelper, setexplode, getlabel, validatemust, validateonlyoneof, validateonlyif, validatemuststartwith, validatenotstartwith, validatemustendwith, validatenotendwith, validatemustcontain, validatenotcontain, validateequalto, validatenotequalto, validatedatatype, validateregularexpression, validateadditionalcheck, validatemustbeunique, getvisibility, getonenterbehavior, getonentercode, applyonenterbehavior, shouldpersist, getdbdatatype, getdbfieldname, _getmaxlength, _gettagstringevents, getvalue, _gettagstringvalue, _gettagstringstyles, _gettagstringadditionaltags, getcaption, getcaptionforformoutput, geterror, gethelp, _highlightaccesskey, _getaccesskey, getfieldashidden, _getfieldnameforhtml, hasjavascript, ismust, _anyifcase, _markasused, _getbsdatainfonumber, isfilledin, _evalwrap, unpersisttrigger, geterrormessage, &serialize, unserialize, &encrypt, &decrypt, initfrompost |
|
|
|
Methods inherited from Bs_Object |
| isex, isexception, tostring, tohtml, persist, unpersist, bs_object, bbsetoutput, bbawake, bbisawake, bbxmsg, bbxfunctionstart, bbxfunctionend, bbxecho, bbxvar, bbxvardump, bbforcetrace, bbbufferstart, bbbufferget, bbbufferendflush, bbbufferendclean |
|
|
|
|
|
Fields inherited from Bs_FormField |
| $_bs_string, $_bs_array, $_bs_htmlutil, $_bs_date, $fieldtype, $caption, $defaulterrormessage, $errormessage, $errortype, $level, $editability, $accessrights, $visibility, $isused, $valuedefault, $valuedefaulttype, $valuereceived, $valuedisplay, $valueinternal, $savetodb, $dbfieldname, $dbdatatype, $dbnotnull, $dbprimarykey, $dbkey, $dbindexfulltext, $dbautoincrement, $dbunique, $dbforeignkey, $dbattributes, $explodeeval, $_explodearray, $direction, $styles, $advancedstyles, $events, $onenter, $additionaltags, $bsdatatype, $bsdatainfo, $bsdatamanipulation, $bsdatamanipvar, $enforce, $_must, $must, $mustif, $mustoneof, $mustoneofif, $onlyoneof, $onlyif, $onlyoneofif, $muststartwith, $notstartwith, $mustendwith, $notendwith, $mustcontain, $notcontain, $equalto, $notequalto, $mustbeunique, $regularexpression, $additionalcheck, $trim, $remove, $removei, $replace, $replacei, $case, $codepostreceive, $codepostload, $this, $charsrule |
|
Fields inherited from Bs_FormElement |
| $persister, $persisterid, $_form, $name, $elementtype, $formid, $container, $orderid, $elementstringformat, $persistervarsettings, $this |
|
Private Field Summary |
| int |
$sizehow large the select field should be displayed. needs to be >1 for multiple. |
| bool |
$multipleif the user is able to select multiple values, not just one. |
| string |
$optionsTypehow to fill in the option tags for this select field. |
| array |
$_optionsmade up in _prepareOptions() using $optionsHard and $optionsEval. |
| array |
$optionsHardthe options that are selectable for the user. |
| mixed |
$optionsEvalphp code to be evaluated. has to return an array (hash or vector) |
| unknown |
$minLengththe min length the field value needs to be. if it's not a $must field, |
| unknown |
$maxLengththe max length the field value can be. |
|
|
|
Public Method Details |
Bs_FormFieldSelect |
|
public void Bs_FormFieldSelect( )
|
| |
Constructor.
|
| Returns |
void |
|
&getField |
|
public string &getField( [ string $addEnforceCheckbox ] )
|
| |
Returns some html code to display the field on a website in a form.
overwrites parent method.
|
| Parameter |
|
| string |
$addEnforceCheckbox |
= >>TRUE<< |
|
default is TRUE. adds the enforce checkbox automatically, if needed. see (parent::)addEnforceCheckbox(). |
|
| Returns |
string some html code |
|
getOptionStringForValue |
|
public string getOptionStringForValue( mixed $value, [ string $lang ] )
|
| |
returns the displayed value for an internal value.
example:you have <option value="ca">Canada</option>getOptionStringForValue('ca') returns 'Canada'.big note: this method is (and should be) identical in Bs_FormFieldRadio and Bs_FormFieldSelect.
|
| Parameter |
|
| mixed |
$value |
|
|
(string or so) |
|
|
| string |
$lang |
= >>null<< |
|
(...) |
|
| Returns |
string |
|
inputManipulate |
|
public void inputManipulate( )
|
| |
overwrite parent method cause we don't want to manipulate anything here.
Warning: documentation is missing.
|
| Returns |
void |
|
inputValidate |
|
public mixed inputValidate( [ mixed $paramValue ] )
|
| |
validate the user inputs according to the object vars.
overwrites parent method. read manual there. additional information:the order for data validation is: (-- means check omitted here)1) must 5) --mustStartWith 9) --mustContain 13) --mustBeUnique2a) onlyOneOf 6) --notStartWith 10) --notContain 14) --regularExpression2b) onlyIf3) minLength 7) --mustEndWith 11) --equalTo4) maxLength 8) --notEndWith 12) --notEqualTo
Warning: documentation is missing.
|
| Parameter |
|
| mixed |
$paramValue |
= >>NULL<< |
|
(only used internally!!!) |
|
| Returns |
mixed |
|
validateMinLength |
|
public mixed validateMinLength( mixed &$v )
|
| |
checks the minLength case.
overwrites parent method. for a select field the minLength has another meaning.it's the number of min. selectable elements. if it doesn't have the 'multiple'property the setting is ignored.
Warning: documentation is missing.
|
| Parameter |
|
| mixed |
&$v |
|
|
(the value the user submitted, should be a string here) |
|
| Returns |
mixed (bool)TRUE if ok, (string)error message if not. |
| See Also |
$minLength |
|
validateMaxLength |
|
public mixed validateMaxLength( mixed &$v, int &$vLength )
|
| |
checks the maxLength case.
overwrites parent method. for a select field the maxLength has another meaning.it's the number of max. selectable elements. if it doesn't have the 'multiple'property the setting is ignored.
Warning: documentation is missing.
|
| Parameter |
|
| mixed |
&$v |
|
|
(the value the user submitted, should be a string here) |
|
|
| int |
&$vLength |
|
|
the length of $v. this way we don't have to do strlen() again. |
|
| Returns |
mixed (bool)TRUE if ok, (string)error message if not. |
| See Also |
$maxLength |
|
|
Private Method Details |
_getOptionsString |
|
private string _getOptionsString( )
|
| |
returns a string with the option tags to send to the client.
|
| Returns |
string |
|
_prepareOptionsData |
|
private array _prepareOptionsData( )
|
| |
prepares the options to select from for this field.
big note: this method is (and should be) identical in Bs_FormFieldRadio and Bs_FormFieldSelect.
|
| Returns |
array |
|
_getDefaultValue |
|
private string _getDefaultValue( )
|
| |
returns the default value somehow. depends on form->step.
outsourced this from _getOptionsString().
|
| Returns |
string i think, maybe an array is possible too.) |
|
_prepareOptions |
|
private void _prepareOptions( [ string $suppressErrors ] )
|
| |
sets $this->_options based on the vars $optionsHard and $optionsEval.
|
| Parameter |
|
| string |
$suppressErrors |
= >>FALSE<< |
|
(default is FALSE. it's really hard to debug something with this set to true. you won't see anything.) |
|
| Returns |
void |
| See Also |
$optionsType, $optionsHard, $optionsEval, $_options |
|
|
Private Field Details |
$size |
|
private int $size
>><<
how large the select field should be displayed. needs to be >1 for multiple.
if not set it won't be written to the client, which equals to a value of '1'.
|
|
$multiple |
|
private bool $multiple
>><<
if the user is able to select multiple values, not just one.
$size needs to be >1 then. if not set it's FALSE.
|
|
$optionsType |
|
private string $optionsType
>><<
how to fill in the option tags for this select field.
one of 'eval' or 'hard'.if not set, the one var that is used is used :) if both are used(speaking of $optionsHard and $optionsEval) then $optionsHard isthe default.
|
| See Also |
_prepareOptions(), $optionsHard, $optionsEval, $_options |
|
$_options |
|
private array $_options
>><<
made up in _prepareOptions() using $optionsHard and $optionsEval.
|
| See Also |
_prepareOptions(), $optionsType, $optionsHard, $optionsEval |
|
$optionsHard |
|
private array $optionsHard
>><<
the options that are selectable for the user.
the following data structures are allowed:array('1'=>'one', '2'=>'two', '4'=>'four');array('en'=>array('1'=>'one','2'=>'two','3'=>'three'), 'de'=>array('1'=>'eins','2'=>'zwei','3'=>'drei'), 'fr'=>array('1'=>'un','2'=>'deux','3'=>'trois'));while these are not:'one';array('one', 'two', 'three');array('en'=>'one', 'de'=>'eins', 'fr'=>'un');array('en'=>array('one','two','three'), 'de'=>array('eins','zwei','drei'), 'fr'=>array('un','deux','trois'));because it would not be possible to know the difference sometimes.this means: even if you have only one default value, it must be an array. and you alwaysneed key=>val, even if the key and the value is the same.
|
| See Also |
_prepareOptions(), $optionsType, $optionsEval, $_options |
|
$optionsEval |
|
private mixed $optionsEval
>><<
php code to be evaluated. has to return an array (hash or vector)
that will be used for the option tags of this select field.the code is executed in $this->_prepareOptions() so it's in thescope of a method of this object. this means you can use varsfrom here etc.language dependant. ya know what i mean.
|
| See Also |
_prepareOptions(), $optionsType, $optionsHard, $_options |
|
$minLength |
|
private unknown $minLength
>><<
the min length the field value needs to be. if it's not a $must field,
a value shorter than $minLength is not accepted while an empty value is.note I: for the field types 'checkbox' and 'radio' this setting is ignored.because the user cannot do anything about it. it's up to the webmasternot to do shit.note II: for the field type 'select' it's the number of min. selectable elements.if it doesn't have the 'multiple' property the setting is ignored.
|
|
$maxLength |
|
private unknown $maxLength
>><<
the max length the field value can be.
if the form tag supports it, it will be directly added like this:<input maxlength=$maxLength>it will be checked serverside anyway. someone could hack it.if not set, it'll be something that makes sense based on $bsDataType:number => 20 username => 20 domain => 80 datetime => 19text => 500 password => 20 host => 80 timestamp => 8blob => 65535 zipcode => 10 date => 10html => 65535 price => 20 time => 8email => 80 creditcard => 16 month => 2url => 200 ip => 15 year => 4there's room for more logic: if the value is made up based on $bsDataType (list above)and $dbDataType is set, the value should be no bigger than the db field types max length,eg char/varchar=255, int=11, blob=65535, ...note I: for the field types 'checkbox' and 'radio' this setting is ignored.because the user cannot do anything about it. it's up to the webmasternot to do shit.note II: for the field type 'select' it's the number of max. selectable elements.if it doesn't have the 'multiple' property the setting is ignored.
|
| See Also |
$this |
|
|
Private Constant Details |
BS_FORMFIELDSELECT_VERSION
define( BS_FORMFIELDSELECT_VERSION, >>4.0.$x$<< )
Case: default: case sensitive
|
|
|
|
|
|
| PHPDoc 1.0beta |