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

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • 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

  • EditableCheckbox
  • EditableCheckboxGroupField
  • EditableCountryDropdownField
  • EditableDateField
  • EditableDateTimeField
  • EditableDropdown
  • EditableEmailField
  • EditableFileField
  • EditableFormField
  • EditableFormHeading
  • EditableHiddenField
  • EditableLiteralField
  • EditableMemberListField
  • EditableMultipleOptionField
  • EditableNumericField
  • EditableOption
  • EditablePhoneField
  • EditableRadioField
  • EditableSiteAgreementField
  • EditableTextField
  • EditableTimeField
  • FieldEditor
  • SubmittedFileField
  • SubmittedForm
  • SubmittedFormField
  • SubmittedFormReportField
  • UserDefinedForm
  • UserDefinedForm_EmailRecipient
  • UserDefinedForm_SubmittedFormEmail
  • UserFormsVersionedTask
 1 <?php
 2 /**
 3  * EditableTextField
 4  *
 5  * This control represents a user-defined text field in a user defined form
 6  *
 7  * @package userforms
 8  */
 9 
10 class EditableTextField extends EditableFormField {
11 
12     static $singular_name = 'Text Field';
13     
14     static $plural_name = 'Text Fields';
15     
16     static $patterns = array('letters', 'digits');
17         
18     static function get_patterns() {
19         $patterns = array('' => _t('EditableFormField.NOTSELECTED'));
20         foreach(self::$patterns as $pattern) {
21             $patterns[$pattern] = _t("EditableTextField.PatternTitle_{$pattern}");
22         }
23         return $patterns;
24     }
25     
26     static function get_pattern($pattern_title) {
27         return _t("EditableTextField.PatternValue_{$pattern_title}");
28     }
29     
30     function getFieldConfiguration() {
31         $fields = parent::getFieldConfiguration();
32         
33         $min = ($this->getSetting('MinLength')) ? $this->getSetting('MinLength') : '';
34         $max = ($this->getSetting('MaxLength')) ? $this->getSetting('MaxLength') : '';
35         
36         $rows = ($this->getSetting('Rows')) ? $this->getSetting('Rows') : '1';
37         $pattern = ($this->getSetting('Pattern')) ? $this->getSetting('Pattern') : '';
38         
39         $extraFields = new FieldSet(
40             new FieldGroup(_t('EditableTextField.TEXTLENGTH', 'Text length'),               
41                 new TextField($this->getSettingName('MinLength'), "", $min),
42                 new TextField($this->getSettingName('MaxLength'), " - ", $max)              
43             ),
44             new TextField($this->getSettingName('Rows'), _t('EditableTextField.NUMBERROWS', 'Number of rows'), $rows),
45             new TextField($this->getSettingName('Pattern'), _t('EditableTextField.PATTERN', 'Pattern'), $pattern) //, self::get_patterns()
46         );
47         if ($autocompletes = EditableFormField::get_possible_autocompletes(true)) {
48             $autocomplete = ($this->getSetting('Autocomplete')) ? $this->getSetting('Autocomplete') : '';
49             $extraFields->push(new DropdownField($this->getSettingName('Autocomplete'), _t('EditableTextField.AUTOCOMPLETE', 'Autocomplete'), $autocompletes, $autocomplete));
50         }
51         
52         $fields->merge($extraFields);
53         
54         return $fields;     
55     }
56 
57     /**
58      * @return TextareaField|TextField
59      */
60     function getFormField() {
61         if($this->getSetting('Rows') && $this->getSetting('Rows') > 1) {
62             $field = new TextareaField($this->Name, $this->Title, $this->getSetting('Rows'));
63         }
64         else {
65             $field = new TextField($this->Name, $this->Title, null, $this->getSetting('MaxLength'));
66         }
67         if ($this->getSetting('Pattern')) {
68             $field->setHTML5Attribute('pattern', self::get_pattern($this->getSetting('Pattern')));
69         }
70         if ($this->getSetting('Autocomplete')) {
71             $field->setHTML5Attribute('autocomplete', $this->getSetting('Autocomplete'));
72         }
73         return $field;
74     }
75     
76     /**
77      * Return the validation information related to this field. This is 
78      * interrupted as a JSON object for validate plugin and used in the 
79      * PHP. 
80      *
81      * @see http://docs.jquery.com/Plugins/Validation/Methods
82      * @return array
83      */
84     public function getValidation() {
85         $options = parent::getValidation();
86         
87         if($this->getSetting('MinLength')) 
88             $options['minlength'] = $this->getSetting('MinLength');
89             
90         if($this->getSetting('MaxLength')) 
91             $options['maxlength'] = $this->getSetting('MaxLength');
92         
93         return $options;
94     }
95 }
[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.2 API Docs API documentation generated by ApiGen 2.8.0