/**
  * @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);
 }
示例#2
0
 /**
  * Quick smoke test to ensure that text with unicodes is being displayed properly in readonly fields.
  */
 function testReadonlyDisplayUnicodes()
 {
     $inputText = "These are some unicodes: äöü";
     $field = new TextareaField("Test", "Test");
     $field->setValue($inputText);
     $field = $field->performReadonlyTransformation();
     $this->assertContains('These are some unicodes: äöü', $field->Field());
 }
 /**
  * HTML for the column, content of the <td> element.
  *
  * @param  GridField $gridField
  * @param  DataObject $record - Record displayed in this row
  * @param  string $columnName
  * @return string - HTML for the column. Return NULL to skip.
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     $field = new TextareaField('MetaDescription');
     $value = $gridField->getDataFieldValue($record, $columnName);
     $value = $this->formatValue($gridField, $record, $columnName, $value);
     $field->setName($this->getFieldName($field->getName(), $gridField, $record));
     $field->setValue($value);
     return $field->Field() . $this->getErrorMessages();
 }
示例#4
0
    /**
     * Quick smoke test to ensure that text is being encoded properly.
     */
    function testTextEncoding()
    {
        $inputText = "This is my <text>\nWhat's on a new-line?\nThese are some unicodes: äöü&<>";
        $field = new TextareaField("Test", "Test", 5, 20);
        $field->setValue($inputText);
        $this->assertEquals(<<<HTML
<textarea id="Test" name="Test" rows="5" cols="20">This is my &lt;text&gt;
What's on a new-line?
These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;</textarea>
HTML
, $field->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 setValue($value)
 {
     // Regenerate links prior to preview, so that the editor can see them.
     $value = Image::regenerate_html_links($value);
     return parent::setValue($value);
 }
 function __construct($controller, $name, $speaker = null, $member = null, $email = null)
 {
     // Get the city for the current member
     if ($member) {
         $country = $member->Country;
     } else {
         $country = '';
     }
     // Fields
     $FirstNameField = new TextField('FirstName', "Speaker's First Name");
     $LastNameField = new TextField('LastName', "Speaker's Last Name");
     $TitleField = new TextField('Title', "Speaker's Title");
     $BioField = new TextAreaField('Bio', "Speaker's Bio");
     // ID Fields
     $SpeakerIDField = new HiddenField('SpeakerID', 'SpeakerID', "");
     $MemberIDField = new HiddenField('MemberID', 'MemberID');
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwiiterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     // Upload Speaker Photo
     $PhotoField = new CustomUploadField('Photo', 'Upload a speaker photo');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 2;
     // 1 MB
     $size = $sizeMB * 1024 * 1024;
     // 1 MB in bytes
     $PhotoField->getValidator()->setAllowedMaxFileSize($size);
     $PhotoField->setCanPreviewFolder(false);
     // Don't show target filesystem folder on upload field
     // Opt In Field
     $OptInField = new CheckboxField('AvailableForBureau', "I'd like to be in the speaker bureau.");
     $Divider = new LiteralField('hr', '<hr/>');
     // Funded Travel
     $FundedTravelField = new CheckboxField('FundedTravel', "My Company would be willing to fund my travel to events.");
     // Country Field
     $CountryCodes = CountryCodes::$iso_3166_countryCodes;
     $CountryField = new DropdownField('Country', 'Country', $CountryCodes);
     $CountryField->setEmptyString('-- Select One --');
     $CountryField->setValue($country);
     $ExpertiseField = new TextareaField('Expertise', 'Topics of interest (one per line)');
     // Load Existing Data if present
     if ($speaker) {
         $this->record = $speaker;
         $FirstNameField->setValue($speaker->FirstName);
         $LastNameField->setValue($speaker->LastName);
         $BioField->setValue($speaker->Bio);
         $SpeakerIDField->setValue($speaker->ID);
         $MemberIDField->setValue($speaker->MemberID);
         $TitleField->setValue($speaker->Title);
         $IRCHandleField->setValue($speaker->IRCHandle);
         $TwiiterNameField->setValue($speaker->TwitterName);
         $OptInField->setValue($speaker->AvailableForBureau);
         $FundedTravelField->setValue($speaker->FundedTravel);
         $ExpertiseField->setValue($speaker->Expertise);
         $PhotoField->setValue(null, $speaker);
     } elseif ($member) {
         $FirstNameField->setValue($member->FirstName);
         $LastNameField->setValue($member->LastName);
         $BioField->setValue($member->Bio);
         $MemberIDField->setValue($member->ID);
         $IRCHandleField->setValue($member->IRCHandle);
         $TwiiterNameField->setValue($member->TwitterName);
     }
     $fields = new FieldList($FirstNameField, $LastNameField, $TitleField, $BioField, $SpeakerIDField, $MemberIDField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, $IRCHandleField, $TwiiterNameField, $PhotoField, $Divider, $OptInField, $FundedTravelField, $CountryField, $ExpertiseField);
     $actions = new FieldList(new FormAction('addAction', 'Save Speaker Details'));
     $validator = new RequiredFields('FirstName', 'LastName', 'Title');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
示例#8
0
	/**
	 * Quick smoke test to ensure that text is being encoded properly.
	 */
	function testTextEncoding() {
		$inputText = "This is my <text>These are some unicodes: äöü&<>";
		$field = new TextareaField("Test", "Test");
		$field->setValue($inputText);
		$this->assertContains('This is my &lt;text&gt;These are some unicodes: &auml;&ouml;&uuml;&amp;&lt;&gt;', $field->Field());
	}