public function getCMSFields()
 {
     $fields = new FieldList();
     $fields->push(new TabSet('Root', new Tab('Main', _t('SiteTree.TABMAIN', 'Main'), new TextField('Title', _t('UniadsObject.db_Title', 'Title')))));
     if ($this->ID) {
         $previewLink = Director::absoluteBaseURL() . 'admin/' . UniadsAdmin::config()->url_segment . '/UniadsObject/preview/' . $this->ID;
         $fields->addFieldToTab('Root.Main', new ReadonlyField('Impressions', _t('UniadsObject.db_Impressions', 'Impressions')), 'Title');
         $fields->addFieldToTab('Root.Main', new ReadonlyField('Clicks', _t('UniadsObject.db_Clicks', 'Clicks')), 'Title');
         $fields->addFieldsToTab('Root.Main', array(DropdownField::create('CampaignID', _t('UniadsObject.has_one_Campaign', 'Campaign'), DataList::create('UniadsCampaign')->map())->setEmptyString(_t('UniadsObject.Campaign_none', 'none')), DropdownField::create('ZoneID', _t('UniadsObject.has_one_Zone', 'Zone'), DataList::create('UniadsZone')->map())->setEmptyString(_t('UniadsObject.Zone_select', 'select one')), new NumericField('Weight', _t('UniadsObject.db_Weight', 'Weight (controls how often it will be shown relative to others)')), new TextField('TargetURL', _t('UniadsObject.db_TargetURL', 'Target URL')), new Treedropdownfield('InternalPageID', _t('UniadsObject.has_one_InternalPage', 'Internal Page Link'), 'Page'), new CheckboxField('NewWindow', _t('UniadsObject.db_NewWindow', 'Open in a new Window')), $file = new UploadField('File', _t('UniadsObject.has_one_File', 'Advertisement File')), $AdContent = new TextareaField('AdContent', _t('UniadsObject.db_AdContent', 'Advertisement Content')), $Starts = new DateField('Starts', _t('UniadsObject.db_Starts', 'Starts')), $Expires = new DateField('Expires', _t('UniadsObject.db_Expires', 'Expires')), new NumericField('ImpressionLimit', _t('UniadsObject.db_ImpressionLimit', 'Impression Limit')), new CheckboxField('Active', _t('UniadsObject.db_Active', 'Active')), new LiteralField('Preview', '<a href="' . $previewLink . '" target="_blank">' . _t('UniadsObject.Preview', 'Preview this advertisement') . "</a>")));
         $app_categories = File::config()->app_categories;
         $file->setFolderName($this->config()->files_dir);
         $file->getValidator()->setAllowedMaxFileSize(array('*' => $this->config()->max_file_size));
         $file->getValidator()->setAllowedExtensions(array_merge($app_categories['image'], $app_categories['flash']));
         $AdContent->setRows(10);
         $AdContent->setColumns(20);
         $Starts->setConfig('showcalendar', true);
         $Starts->setConfig('dateformat', i18n::get_date_format());
         $Starts->setConfig('datavalueformat', 'yyyy-MM-dd');
         $Expires->setConfig('showcalendar', true);
         $Expires->setConfig('dateformat', i18n::get_date_format());
         $Expires->setConfig('datavalueformat', 'yyyy-MM-dd');
         $Expires->setConfig('min', date('Y-m-d', strtotime($this->Starts ? $this->Starts : '+1 days')));
     }
     $this->extend('updateCMSFields', $fields);
     return $fields;
 }
 /**
  *
  * @param SS_Request $request
  * @return Form 
  */
 public function getEditForm($id = null, $fields = null)
 {
     $form = parent::getEditForm($id, $fields);
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         //			return $form;
     }
     if (!Permission::check('ADMIN')) {
         return $form;
     }
     $fields = $form->Fields();
     $config = $this->searchService->localEngineConfig();
     $allow = $config ? $config->RunLocal : null;
     $fields->push(new CheckboxField('RunLocal', _t('SolrAdmin.RUN_LOCAL', 'Run local Jetty instance of Solr?'), $allow));
     if ($allow) {
         $status = $this->searchService->localEngineStatus();
         if (!$status) {
             $fields->push(new CheckboxField('Start', _t('SolrAdmin.START', 'Start Solr')));
         } else {
             $fields->push(new CheckboxField('Kill', _t('SolrAdmin.Kill', 'Kill Solr process (' . $status . ')')));
         }
         $log = $this->searchService->getLogData(100);
         $log = array_reverse($log);
         $fields->push($logtxt = new TextareaField('Log', _t('SolrAdmin.LOG', 'Log')));
         $logtxt->setColumns(20)->setRows(15)->setValue(implode($log));
     }
     $form->Actions()->push(new FormAction('saveconfig', _t('SolrAdmin.SAVE', 'Save')));
     $form->Actions()->push(new FormAction('reindex', _t('SolrAdmin.REINDEX', 'Reindex')));
     //		$actions = new FieldSet();
     //		$form = new Form($this, 'EditForm', $fields, $actions);
     return $form;
 }
 public function getFieldConfiguration()
 {
     $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML");
     $textAreaField->setRows(4);
     $textAreaField->setColumns(20);
     return new FieldList($textAreaField, new CheckboxField($this->getSettingName('HideFromReports'), _t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'), $this->getSetting('HideFromReports')));
 }
 function TypoForm()
 {
     $array = array('green', 'yellow', 'blue', 'pink', 'orange');
     $form = new Form($this, 'TestForm', $fields = FieldList::create(HeaderField::create('HeaderField1', 'HeaderField Level 1', 1), LiteralField::create('LiteralField', '<p>All fields up to EmailField are required and should be marked as such</p>'), TextField::create('TextField1', 'Text Field Example 1'), TextField::create('TextField2', 'Text Field Example 2'), TextField::create('TextField3', 'Text Field Example 3'), TextField::create('TextField4', ''), HeaderField::create('HeaderField2b', 'Field with right title', 2), $textAreaField = new TextareaField('TextareaField', 'Textarea Field'), EmailField::create('EmailField', 'Email address'), HeaderField::create('HeaderField2c', 'HeaderField Level 2', 2), DropdownField::create('DropdownField', 'Dropdown Field', array(0 => '-- please select --', 1 => 'test AAAA', 2 => 'test BBBB')), OptionsetField::create('OptionSF', 'Optionset Field', $array), CheckboxSetField::create('CheckboxSF', 'Checkbox Set Field', $array), CountryDropdownField::create('CountryDropdownField', 'Countries'), CurrencyField::create('CurrencyField', 'Bling bling', '$123.45'), HeaderField::create('HeaderField3', 'Other Fields', 3), NumericField::create('NumericField', 'Numeric Field '), DateField::create('DateField', 'Date Field'), DateField::create('DateTimeField', 'Date and Time Field'), CheckboxField::create('CheckboxField', 'Checkbox Field')), $actions = FieldList::create(FormAction::create('submit', 'Submit Button')), $requiredFields = RequiredFields::create('TextField1', 'TextField2', 'TextField3', 'ErrorField1', 'ErrorField2', 'EmailField', 'TextField3', 'RightTitleField', 'CheckboxField', 'CheckboxSetField'));
     $textAreaField->setColumns(45);
     $form->setMessage('warning message', 'warning');
     return $form;
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->replaceField('ItemTemplate', $ta = new TextareaField('ItemTemplate', _t('ListingTemplate.ITEM_TEMPLATE', 'Item Template (use the Items variable to iterate over)')));
     $ta->setRows(20);
     $ta->setColumns(120);
     return $fields;
 }
 public function getFieldConfiguration()
 {
     $customSettings = unserialize($this->CustomSettings);
     $content = isset($customSettings['Content']) ? $customSettings['Content'] : '';
     $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML", $content);
     $textAreaField->setRows(4);
     $textAreaField->setColumns(20);
     return new FieldList($textAreaField, new CheckboxField($this->getSettingName('HideFromReports'), _t('EditableLiteralField.HIDEFROMREPORT', 'Hide from reports?'), $this->getSetting('HideFromReports')));
 }
 public function getFieldConfiguration()
 {
     $customSettings = unserialize($this->CustomSettings);
     $content = isset($customSettings['Content']) ? $customSettings['Content'] : '';
     $textAreaField = new TextareaField($this->getSettingName('Content'), "HTML", $content);
     $textAreaField->setRows(4);
     $textAreaField->setColumns(20);
     return new FieldList($textAreaField);
 }
 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     if ($this->disableEditor) {
         $tfa = new TextareaField('HTML');
         $tfa->setRows(30);
         $tfa->setColumns(150);
         $fields->addFieldToTab('Root.Main', $tfa);
     }
     return $fields;
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new TextareaField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     $field->setColumns(50);
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     return $this->buildDependantRules($rsvp, $question, $field);
 }
 /**
  * Return the linked file view form, which shows a readonly form that contains the
  * source text of the file being viewed.
  * @throws Exception
  * @return Form
  */
 public function LinkedFileViewForm()
 {
     // grab the parameters
     if (isset($_REQUEST['ID'])) {
         $id = addslashes($_REQUEST['ID']);
     } else {
         throw new Exception("invalid ID");
     }
     // Extract parameters from this ID. It's base 64 of
     // templateID:path
     $id = base64_decode($id);
     $params = explode(':', $id);
     if (count($params) != 2) {
         throw Exception("Invalid params, expected 2 components");
     }
     $dynamicTemplateId = $params[0];
     $path = $params[1];
     $form = new Form($this, "LinkedFileViewForm", new FieldList(new LabelField("Filename", "File: " . $path), $sourceTextField = new TextareaField("SourceText", ""), new HiddenField('ID', 'ID'), new HiddenField('BackURL', 'BackURL', $this->Link())), new FieldList(new FormAction('cancelFileEdit', _t('DynamicTemplate.CANCELFILEEDIT', 'Cancel'))));
     $form->setTemplate('FilesEditorForm');
     // Get the contents of the file
     $contents = file_get_contents(BASE_PATH . $path);
     $sourceTextField->setRows(20);
     $sourceTextField->setColumns(150);
     $sourceTextField->setValue($contents);
     $form->HelpType = null;
     return $form;
 }
 public function StatusForm()
 {
     $fields = new FieldList($taf = new TextareaField('Content', _t('MicroBlog.POST', 'Post')));
     $taf->setRows(3);
     $taf->setColumns(120);
     $actions = new FieldList(new FormAction('savepost', _t('MicroBlog.SAVE', 'Add')));
     $form = new Form($this, 'StatusForm', $fields, $actions);
     return $form;
 }
 function Form()
 {
     $array = array();
     $array[] = "green";
     $array[] = "yellow";
     $array[] = "blue";
     $array[] = "pink";
     $array[] = "orange";
     $errorField0 = new TextField($name = "ErrorField0", $title = "Text Field Example 1");
     $errorField0->setError("message shown when something is good", "good");
     $errorField1 = new TextField($name = "ErrorField1", $title = "Text Field Example 2");
     $errorField1->setError("message shown when something is bad", "bad");
     $errorField2 = new TextField($name = "ErrorField2", $title = "Text Field Example 3");
     $errorField2->setCustomValidationMessage("message shown when something is bad", "bad");
     $errorField3 = new TextField($name = "ErrorField3", $title = "Text Field Example 4");
     $errorField3->setError("there is an error", "required");
     $errorField4 = new TextField($name = "ErrorField4", $title = "Text Field Example 5");
     $errorField4->setCustomValidationMessage("custom validation error");
     $rightTitle = new TextField($name = "RightTitleField", $title = "Left Title is Default");
     $rightTitle->setRightTitle("right title here");
     $readonlyField = new ReadOnlyField($name = "ReadOnlyField", $title = "ReadOnlyField");
     $readonlyField->setValue("read only value");
     $groupedDropdownField = new GroupedDropdownField($name = "dropdown", $title = "Simple Grouped Dropdown", $source = array("primary" => array("1" => "Green", "2" => "Red", "3" => "Blue", "4" => "Orange"), "secondary" => array("11" => "Light Blue", "12" => "Dark Brown", "13" => "Pinkish Red")));
     $form = new Form($controller = $this, $name = "TestForm", $fields = new FieldList(new HeaderField($name = "HeaderField1", $title = "Default Header Field"), new LiteralField($name = "LiteralField", "<p>NOTE: All fields up to EmailField are required and should be marked as such</p>"), new TextField($name = "TextField1", $title = "Text Field Example 1"), new TextField($name = "TextField2", $title = "Text Field Example 2"), new TextField($name = "TextField3", $title = "Text Field Example 3"), new TextField($name = "TextField4", $title = ""), new HeaderField($name = "HeaderField2a", $title = "Error Messages", 2), new LiteralField($name = "ErrorExplanations", '<p>Below are some error messages, some of them only show up after you have placed your cursor on the field and not completed it (i.e. a reminder to complete the field)</p>'), $errorField0, $errorField1, $errorField2, $errorField3, $errorField4, new HeaderField($name = "HeaderField2b", $title = "Field with right title", 2), $rightTitle, $textAreaField = new TextareaField($name = "TextareaField", $title = "Textarea Field"), new EmailField("EmailField", "Email address"), new HeaderField($name = "HeaderField2c", $title = "HeaderField Level 2", 2), new DropdownField($name = "DropdownField", $title = "Dropdown Field", array(0 => "-- please select --", 1 => "test AAAA", 2 => "test BBBB")), new OptionsetField($name = "OptionsetField", $title = "Optionset Field", $array), new CheckboxSetField($name = "CheckboxSetField", $title = "Checkbox Set Field", $array), new CurrencyField($name = "CurrencyField", $title = "Bling bling"), new HeaderField($name = "HeaderField3", $title = "Other Fields", 3), new NumericField($name = "NumericField", $title = "Numeric Field "), new DateField($name = "DateField", $title = "Date Field"), new DateField($name = "DateTimeField", $title = "Date and Time Field"), new FileField($name = "FileField", $title = "File Field"), new UploadField($name = "UploadField", $title = "Upload File"), new ConfirmedPasswordField($name = "ConfirmPasswordField", $title = "Password"), new CheckboxField($name = "CheckboxField", $title = "Checkbox Field"), $groupedDropdownField, new HeaderField($name = "HeaderField4", $title = "Read-only Field", 3), $readonlyField), $actions = new FieldList(new FormAction("signup", "Sign up")), $requiredFields = new RequiredFields("TextField1", "TextField2", "TextField3", "ErrorField1", "ErrorField2", "EmailField", "TextField3", "RightTitleField", "CheckboxField", "CheckboxSetField"));
     $textAreaField->setColumns(7);
     $form->setMessage("warning message", "warning");
     return $form;
 }