public function updateCMSFields(FieldSet $fields) { Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js'); Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js'); Requirements::javascript('newsletter-pagesource/javascript/NewsletterAdmin.js'); $source = new OptionsetField('ContentSource', 'Content Source', array('content' => 'A content block', 'page' => 'A page in the site tree')); $fields->insertBefore($source, 'Content'); $page = new TreeDropdownField('SourcePageID', '', 'SiteTree'); $fields->insertBefore($page, 'Content'); $fields->dataFieldByName('Content')->setTitle(''); }
protected function getUploadFields() { $fields = new FieldSet(new HeaderField($title = sprintf(_t('DataObjectManager.ADDITEM', 'Add %s'), $this->PluralTitle()), $headingLevel = 2), new HeaderField($title = _t('DataObjectManager.UPLOADFROMPC', 'Upload from my computer'), $headingLevel = 3), new SWFUploadField("UploadForm", "Upload", "", array('file_upload_limit' => $this->getUploadLimit(), 'file_queue_limit' => $this->getUploadLimit(), 'browse_button_text' => $this->getBrowseButtonText(), 'upload_url' => Director::absoluteURL('FileDataObjectManager_Controller/handleswfupload'), 'required' => 'true'))); if ($this->allowUploadFolderSelection) { $fields->insertBefore(new DropdownField('UploadFolder', '', $this->getUploadFolderHierarchy(0), null, null, "-- Select a folder --"), "Upload"); } return $fields; }
function testFieldPosition() { $set = new FieldSet(new TextField('A'), new TextField('B'), new TextField('C')); $this->assertEquals(0, $set->fieldPosition('A')); $this->assertEquals(1, $set->fieldPosition('B')); $this->assertEquals(2, $set->fieldPosition('C')); $set->insertBefore(new TextField('AB'), 'B'); $this->assertEquals(0, $set->fieldPosition('A')); $this->assertEquals(1, $set->fieldPosition('AB')); $this->assertEquals(2, $set->fieldPosition('B')); $this->assertEquals(3, $set->fieldPosition('C')); unset($set); }
/** * Get the fields needed by the forum module * * @param bool $showIdentityURL Should a field for an OpenID or an i-name * be shown (always read-only)? * @return FieldSet Returns a FieldSet containing all needed fields for * the registration of new users */ function getForumFields($showIdentityURL = false, $addmode = false) { $gravatarText = DataObject::get_one("ForumHolder", "\"AllowGravatars\" = 1") ? '<small>' . _t('ForumRole.CANGRAVATAR', 'If you use Gravatars then leave this blank') . '</small>' : ""; $personalDetailsFields = new CompositeField(new HeaderField("PersonalDetails", _t('ForumRole.PERSONAL', 'Personal Details')), new LiteralField("Blurb", "<p id=\"helpful\">" . _t('ForumRole.TICK', 'Tick the fields to show in public profile') . "</p>"), new TextField("Nickname", _t('ForumRole.NICKNAME', 'Nickname')), new CheckableOption("FirstNamePublic", new TextField("FirstName", _t('ForumRole.FIRSTNAME', 'First name'))), new CheckableOption("SurnamePublic", new TextField("Surname", _t('ForumRole.SURNAME', 'Surname'))), new CheckableOption("OccupationPublic", new TextField("Occupation", _t('ForumRole.OCCUPATION', 'Occupation')), true), new CheckableOption('CompanyPublic', new TextField('Company', _t('ForumRole.COMPANY', 'Company')), true), new CheckableOption('CityPublic', new TextField('City', _t('ForumRole.CITY', 'City')), true), new CheckableOption("CountryPublic", new CountryDropdownField("Country", _t('ForumRole.COUNTRY', 'Country')), true), new CheckableOption("EmailPublic", new EmailField("Email", _t('ForumRole.EMAIL', 'Email'))), new ConfirmedPasswordField("Password", _t('ForumRole.PASSWORD', 'Password')), new SimpleImageField("Avatar", _t('ForumRole.AVATAR', 'Upload avatar ') . ' ' . $gravatarText), new ReadonlyField("ForumRank", _t('ForumRole.RATING', 'User rating'))); $personalDetailsFields->setID('PersonalDetailsFields'); $fieldset = new FieldSet($personalDetailsFields); if ($showIdentityURL) { $fieldset->insertBefore(new ReadonlyField('IdentityURL', _t('ForumRole.OPENIDINAME', 'OpenID/i-name')), 'Password'); $fieldset->insertAfter(new LiteralField('PasswordOptionalMessage', '<p>' . _t('ForumRole.PASSOPTMESSAGE', 'Since you provided an OpenID respectively an i-name the password is optional. If you enter one, you will be able to log in also with your e-mail address.') . '</p>'), 'IdentityURL'); } $this->owner->extend('updateForumFields', $fieldset); return $fieldset; }
/** * @deprecated 2.3 Use insertBefore */ public function insertBeforeRecursive($field, $insertBefore) { return $this->children->insertBefore($field, $insertBefore); }
/** * Build a FieldSet of the FormAction fields for the given step. * * If the current step is the final step, we push in a submit button, which * calls the action {@link finish()} to finalise the submission. Otherwise, * we push in a next button which calls the action {@link next()} to determine * where to go next in our step process, and save any form data collected. * * If there's a previous step (a step that has the current step as it's next * step class), then we allow a previous button, which calls the previous action * to determine which step to go back to. * * If there are any extra actions defined in MultiFormStep->getExtraActions() * then that set of actions is appended to the end of the actions FieldSet we * have created in this method. * * @param $currentStep Subclass of MultiFormStep * @return FieldSet of FormAction objects */ function actionsFor($step) { // Create default multi step actions (next, prev), and merge with extra actions, if any $actions = new FieldSet(); // If the form is at final step, create a submit button to perform final actions // The last step doesn't have a next button, so add that action to any step that isn't the final one if($step->isFinalStep()) { $actions->push(new FormAction('finish', _t('MultiForm.SUBMIT', 'Submit'))); } else { $actions->push(new FormAction('next', _t('MultiForm.NEXT', 'Next'))); } // If there is a previous step defined, add the back button if($step->getPreviousStep() && $step->canGoBack()) { // If there is a next step, insert the action before the next action if($step->getNextStep()) { $actions->insertBefore(new FormAction('prev', _t('MultiForm.BACK', 'Back')), 'action_next'); // Assume that this is the last step, insert the action before the finish action } else { $actions->insertBefore(new FormAction('prev', _t('MultiForm.BACK', 'Back')), 'action_finish'); } } // Merge any extra action fields defined on the step $actions->merge($step->getExtraActions()); return $actions; }
/** * @uses FieldSet->insertBefore() */ public function insertBefore($field, $insertBefore) { $ret = $this->children->insertBefore($field, $insertBefore); $this->sequentialSet = null; return $ret; }