Webylon 3.1 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • auth
  • Booking
  • cart
    • shipping
    • steppedcheckout
  • Catalog
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • CheckboxField
  • CheckboxField_Disabled
  • CheckboxField_Readonly
  • CheckboxSetField
  • DropdownField
  • GroupedDropdownField
  • ListboxField
  • LookupField
  • NullableField
  • OptionsetField
  • ReadonlyField
  • RoomServiceDropdownField
  • SimpleHTMLEditorField
  • SimpleTinyMCEField
  • SimpleWysiwygField
  • StateDropdownField
  • StateProvinceDropdownField
  • TextareaField
  • TextField
 1 <?php
 2 /**
 3  * Read-only complement of {@link DropdownField}.
 4  * Shows the "human value" of the dropdown field for the currently selected value.
 5  * @package forms
 6  * @subpackage fields-basic
 7  */
 8 class LookupField extends DropdownField {
 9 
10     protected $readonly = true;
11     
12     /**
13      * Returns a readonly span containing the correct value.
14      */
15     function Field() {
16         
17         if(trim($this->value) || $this->value === '0') {
18             $this->value = trim($this->value);
19             $source = $this->getSource();
20             if(is_array($source)) {
21                 $mappedValue = isset($source[$this->value]) ? $source[$this->value] : null;
22             } elseif($source instanceof SQLMap) {
23                 $mappedValue = $source->getItem($this->value);
24             }
25         }
26         
27         if(!isset($mappedValue)) $mappedValue = "<i>(none)</i>";
28 
29         if($this->value) {
30             $val = $this->dontEscape
31                 ? ($this->reserveNL?Convert::raw2xml($this->value):$this->value)
32                 : Convert::raw2xml($this->value);
33         } else {
34             $val = '<i>(none)</i>';
35         }
36 
37         $valforInput = $this->value ? Convert::raw2att($val) : "";
38 
39         return "<span class=\"readonly\" id=\"" . $this->id() .
40             "\">$mappedValue</span><input type=\"hidden\" name=\"" . $this->name .
41             "\" value=\"" . $valforInput . "\" />";
42     }
43     
44     function performReadonlyTransformation() {
45         $clone = clone $this;
46         return $clone;
47     }
48 
49     function Type() { 
50         return "lookup readonly";
51     }
52     
53     /**
54      * Override parent behaviour by not merging arrays.
55      */
56     function getSource() {
57         return $this->source;
58     }
59 }
60 
61 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.1 API Docs API documentation generated by ApiGen 2.8.0