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

  • AjaxUniqueTextField
  • AutocompleteTextField
  • ConfirmedPasswordField
  • CreditCardField
  • CurrencyField
  • CurrencyField_Disabled
  • CurrencyField_Readonly
  • EmailField
  • HtmlEditorConfig
  • HtmlEditorField
  • HtmlEditorField_Readonly
  • HtmlEditorField_Toolbar
  • NumericField
  • PasswordField
  • PhoneNumberField
  • UniqueRestrictedTextField
  • UniqueTextField
 1 <?php
 2 /**
 3  * Password input field.
 4  * @package forms
 5  * @subpackage fields-formattedinput
 6  */
 7 class PasswordField extends FormField {
 8 
 9     /**
10      * maxlength of the password field
11      *
12      * @var int
13      */
14     protected $maxLength;
15 
16 
17     /**
18      * Returns an input field, class="text" and type="text" with an optional
19      * maxlength
20      */
21     function __construct($name, $title = null, $value = "", $maxLength = null) {
22         $this->maxLength = $maxLength;
23         parent::__construct($name, $title, $value);
24     }
25 
26 
27     function Field() {
28         $disabled = $this->isDisabled()?"disabled=\"disabled\"":""; 
29         $readonly = $this->isReadonly()?"readonly=\"readonly\"":"";
30         $preparedAttributes = '';
31         if (count($this->extraAttributes)) {        
32             foreach($this->extraAttributes as $k => $v) {
33                 // Note: as indicated by the $k == value item here; the decisions over what to include in the attributes can sometimes get finicky
34                 if(!empty($v) || $v === '0' || $k == 'value') $preparedAttributes .= " $k=\"" . Convert::raw2att($v) . "\"";
35             }
36         }
37         if($this->maxLength) {
38             return "<input $preparedAttributes class=\"text\" type=\"password\" id=\"" . $this->id() .
39                 "\" name=\"{$this->name}\" value=\"" . $this->attrValue() .
40                 "\" maxlength=\"$this->maxLength\" size=\"$this->maxLength\" $disabled $readonly />"; 
41         } else {
42             return "<input $preparedAttributes class=\"text\" type=\"password\" id=\"" . $this->id() .
43                 "\" name=\"{$this->name}\" value=\"" . $this->attrValue() . "\" $disabled $readonly />"; 
44         }
45     }
46 
47 
48     /**
49      * Makes a pretty readonly field with some stars in it
50      */
51     function performReadonlyTransformation() {
52         $stars = '*****';
53 
54         $field = new ReadonlyField($this->name, $this->title ? $this->title : '', $stars);
55         $field->setForm($this->form);
56         $field->setReadonly(true);
57         return $field;
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