/**
  * Builds a new currency field based on the allowed currencies configured
  *
  * @return FormField
  */
 protected function buildCurrencyField()
 {
     $name = $this->getName();
     $allowedCurrencies = $this->getAllowedCurrencies();
     if ($allowedCurrencies) {
         $field = new DropdownField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'), ArrayLib::is_associative($allowedCurrencies) ? $allowedCurrencies : array_combine($allowedCurrencies, $allowedCurrencies));
     } else {
         $field = new TextField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'));
     }
     $field->setReadonly($this->isReadonly());
     $field->setDisabled($this->isDisabled());
     return $field;
 }
 /**
  * @param ISurveyStep $current_step
  * @param ISurveyQuestionTemplate $question
  * @param ISurveyAnswer $answer
  * @return FormField
  */
 public function build(ISurveyStep $current_step, ISurveyQuestionTemplate $question, ISurveyAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     $field->setValue($question->initialValue());
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     $this->buildDependantRules($current_step, $question, $field);
     return $field;
 }
 /**
  * @param IRSVP $rsvp
  * @param IRSVPQuestionTemplate $question
  * @param IRSVPAnswer $answer
  * @return FormField
  */
 public function build(IRSVP $rsvp, IRSVPQuestionTemplate $question, IRSVPAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     if ($rsvp) {
         $field->setValue($rsvp->findAnswerByQuestion($question)->Value);
     } else {
         $field->setValue($question->initialValue());
     }
     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);
 }
 /**
  * @param ITrackQuestionTemplate $question
  * @param ITrackAnswer $answer
  * @return FormField
  */
 public function build(ITrackQuestionTemplate $question, ITrackAnswer $answer)
 {
     $field = new TextField($question->name(), $question->label());
     $field->setFieldHolderTemplate('BootstrapFieldHolder');
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     } else {
         $field->setValue($question->initialValue());
     }
     if ($question->isReadOnly()) {
         $field->setDisabled(true);
     }
     if ($question->isMandatory()) {
         $field->setAttribute('data-rule-required', 'true');
     }
     if (!is_null($answer)) {
         $field->setValue($answer->value());
     }
     return $field;
 }
 /**
  * @param FieldList $fields
  * @return FieldList|void
  */
 public function updateCMSFields(FieldList $fields)
 {
     $oldFields = $fields->toArray();
     foreach ($oldFields as $field) {
         $fields->remove($field);
     }
     $fields->push(new LiteralField("Title", "<h2>Marketplace Type</h2>"));
     $fields->push(new TextField("Name", "Name"));
     $fields->push(new CheckboxField("Active", "Active"));
     if ($this->owner->ID > 0) {
         $slug_field = new TextField('Slug', 'Slug');
         $slug_field->setReadonly(true);
         $slug_field->setDisabled(true);
         $slug_field->performReadonlyTransformation();
         $fields->push($slug_field);
         $group_field = new TextField('Group', 'Group', $this->owner->AdminGroup()->Title);
         $group_field->setReadonly(true);
         $group_field->setDisabled(true);
         $group_field->performReadonlyTransformation();
         $fields->push($group_field);
     }
     return $fields;
 }
 /**
  * @param bool $bool
  *
  * @return void
  */
 public function setDisabled($bool)
 {
     parent::setDisabled($bool);
     foreach ($this->manualFields as $field) {
         $field->setDisabled($bool);
     }
 }
 function __construct($controller, $name)
 {
     // Name Set
     $MemberIDField = new TextField('MemberID', "Member ID");
     $MemberIDField->setDisabled(true);
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('Surname', "Last Name");
     // Email Addresses
     $PrimaryEmailField = new TextField('Email', "Primary Email Address");
     $SecondEmailField = new TextField('SecondEmail', "Second Email Address");
     $ThirdEmailField = new TextField('ThirdEmail', "Third Email Address");
     // Replace Fields
     $ReplaceBioField = new HiddenField('ReplaceBio', 'ReplaceBio', 0);
     $ReplaceNameField = new HiddenField('ReplaceName', 'ReplaceName', 0);
     $ReplaceSurnameField = new HiddenField('ReplaceSurname', 'ReplaceSurname', 0);
     // Shirt Size Field
     $ShirtSizeField = new DropdownField('ShirtSize', 'Choose A Shirt Size', array('Small' => "Men's Small", 'Medium' => "Men's Medium", 'Large' => "Men's Large", 'XL' => "Men's XL", 'XXL' => "Men's XXL", 'WS' => "Womens Small", 'WM' => "Womens Medium", 'WL' => "Womens Large", 'WXL' => "Womens XL", 'WXXL' => 'Womens XXL'));
     $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest');
     $StatementOfInterestField->addExtraClass('autocompleteoff');
     // Photo
     $PhotoField = new CustomUploadField('Photo', 'Photo <em>(Optional)</em>');
     $PhotoField->setCanAttachExisting(false);
     $PhotoField->setAllowedMaxFileNumber(1);
     $PhotoField->setAllowedFileCategories('image');
     $PhotoField->setTemplateFileButtons('CustomUploadField_FrontEndFIleButtons');
     $PhotoField->setFolderName('profile-images');
     $sizeMB = 1;
     // 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
     // Biography
     $BioField = new TextAreaField('Bio', 'Bio: A Little Bit About You <em>(Optional)</em>', 10, 15);
     // Food Preference
     $FoodPreferenceField = new CheckboxSetField('FoodPreference', 'Do you have any food preferences we can help accomodate?', array('Vegan' => 'Vegan', 'Vegetarian' => 'Vegetarian', 'Gluten' => 'Gluten allergy', 'Peanut' => 'Peanut allergy'));
     // Other Field
     $OtherFoodField = new TextField('OtherFood', 'Other Food Considerations');
     $OtherFoodField->addExtraClass('other-field');
     // IRC and Twitter
     $IRCHandleField = new TextField('IRCHandle', 'IRC Handle <em>(Optional)</em>');
     $TwitterNameField = new TextField('TwitterName', 'Twitter Name <em>(Optional)</em>');
     $LinkedInProfileField = new TextField('LinkedInProfile', 'LinkedIn Profile <em>(Optional)</em>');
     // Associated Projects
     $ProjectsField = new CheckboxSetField('Projects', 'What programs are you involved with? <em>(Optional)</em>', array('Nova' => 'Compute', 'Swift' => 'Object Storage', 'Glance' => 'Image Service', 'Keystone' => 'Identity Service', 'Horizon' => 'Dashboard', 'Quantum' => 'Networking', 'Cinder' => 'Block Storage', 'Ceilometer' => 'Metering/Monitoring', 'Heat' => 'Orchestration', 'Trove' => 'Database Service', 'Ironic' => 'Bare Metal', 'Queue' => 'Queue Service', 'DataProcessing' => 'Data Processing', 'Oslo' => 'Common Libraries', 'Openstack-ci' => 'Infrastructure', 'Openstack-manuals' => 'Documentation', 'QA' => 'Quality Assurance', 'Deployment' => 'Deployment', 'DevStack' => 'DevStack', 'Release' => 'Release Cycle Management'));
     // Other Projects Field
     $OtherProjectField = new TextField('OtherProject', 'Other Project (if one above does not match)');
     $OtherProjectField->addExtraClass('other-field');
     //Newsletter Field
     $subscribedToNewsletterField = new CheckboxField('SubscribedToNewsletter', 'I don\'t mind occasionally receiving updates and communications from the OpenStack Foundation.');
     $DisplayOnSiteField = new CheckboxField('DisplayOnSite', 'Include this bio on openstack.org.');
     // New Gender Field
     $GenderField = new OptionSetField('Gender', 'I identify my gender as:', array('Male' => 'Male', 'Female' => 'Female', 'Specify' => 'Let me specify', 'Prefer not to say' => 'Prefer not to say'));
     $GenderSpecifyField = new TextField('GenderSpecify', 'Specify your gender');
     $GenderSpecifyField->addExtraClass('hide');
     $fields = new FieldList(new LiteralField('header', '<h3 class="section-divider">Public Information</h3>'), $MemberIDField, new HeaderField("First & Last Name"), $FirstNameField, $LastNameField, $ReplaceBioField, $ReplaceNameField, $ReplaceSurnameField, new LiteralField('break', '<hr/>'), $affiliations = new AffiliationField("Affiliations", "Affiliations"), new LiteralField('break', '<hr/>'), $StatementOfInterestField, new LiteralField('instructions', '<p>Your statement of interest should be a few words describing your objectives or plans for OpenStack.</p>'), new LiteralField('break', '<hr/>'), $IRCHandleField, $TwitterNameField, $LinkedInProfileField, $BioField, $PhotoField, new LiteralField('break', '<hr/>'), $ProjectsField, $OtherProjectField, new LiteralField('header', '<h3 class="section-divider">Private Information</h3>'), new HeaderField("Email Addresses"), new LiteralField('instructions', '<p class="info"><strong>If you\'re an active developer on the OpenStack project, please list any email addresses you use to commit code.</strong> (This will really help us avoid duplicates!) If you contributed code ONLY using gerrit, all email addresses you used will be listed on the <a href="https://review.openstack.org/#/settings/web-identities" target="_blank">web identities page</a>. If you have contributed also <em>before</em> gerrit was put in place, please make an effort to remember other email addresses you may have used. Interested in how to <a href="http://wiki.openstack.org/HowToContribute" target="_blank">become a contributor</a>?</p>'), $PrimaryEmailField, new LiteralField('instructions', '<p class="info">This email address is also the account name you use to login.</p>'), $SecondEmailField, $ThirdEmailField, new LiteralField('break', '<hr/>'), $GenderField, $GenderSpecifyField, new LiteralField('instructions', '<p>It\'s perfectly acceptable if you choose not to tell us: we appreciate you becoming a member of OpenStack Foundation. The information will remain private and only used to monitor our effort to improve gender diversity in our community.</p>'), new LiteralField('break', '<hr/>'), $FoodPreferenceField, $OtherFoodField, new LiteralField('break', '<hr/>'), $ShirtSizeField, $subscribedToNewsletterField, $DisplayOnSiteField, new LiteralField('break', '<hr/>'), new TextField('Address', _t('Addressable.ADDRESS', 'Street Address (Line1)')), new TextField('Suburb', _t('Addressable.SUBURB', 'Street Address (Line2)')), new TextField('City', _t('Addressable.CITY', 'City')));
     // Address Continued
     $label = _t('Addressable.STATE', 'State');
     if (is_array($this->allowedStates)) {
         $fields->push(new DropdownField('State', $label, $this->allowedStates));
     } elseif (!is_string($this->allowedStates)) {
         $fields->push(new TextField('State', $label));
     }
     $fields->push(new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode')));
     $label = _t('Addressable.COUNTRY', 'Country');
     if (is_array($this->allowedCountries)) {
         $countryField = new DropdownField('Country', $label, $this->allowedCountries);
         $countryField->setEmptyString('-- Select One --');
         $fields->push($countryField);
     } elseif (!is_string($this->allowedCountries)) {
         $countryField = new CountryDropdownField('Country', $label);
         $countryField->setEmptyString('-- Select One --');
         $fields->push($countryField);
     }
     $fields->push(new LiteralField('break', '<hr/>'));
     $fields->push(new LiteralField('changepassword', '<a href="/Security/changepassword">Click here to change your password</a>'));
     // Create action
     $actions = new FieldList(new FormAction('SaveProfile', 'Save'));
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('FirstName', 'Surname', 'StatementOfInterest', 'Address', 'City'), new RequiredFields('Email', 'Country')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * Adds a translation section
  *
  * @param FieldList $fields The FieldList
  * 
  * @return void
  *
  * @author Sebastian Diel <*****@*****.**>
  * @since 04.04.2013
  */
 public function updateCMSFields(FieldList $fields)
 {
     $this->getCMSFieldsIsCalled = true;
     $fields->findOrMakeTab('Root.SEO')->setTitle($this->owner->fieldLabel('SeoTab'));
     $fields->findOrMakeTab('Root.SocialMedia')->setTitle($this->owner->fieldLabel('SocialMediaTab'));
     $fields->findOrMakeTab('Root.Translations')->setTitle($this->owner->fieldLabel('TranslationsTab'));
     $googleWebmasterCodeField = new TextField('GoogleWebmasterCode', $this->owner->fieldLabel('GoogleWebmasterCode'));
     $googleAnalyticsTrackingCodeField = new TextareaField('GoogleAnalyticsTrackingCode', $this->owner->fieldLabel('GoogleAnalyticsTrackingCode'));
     $googleConversionTrackingCodeField = new TextareaField('GoogleConversionTrackingCode', $this->owner->fieldLabel('GoogleConversionTrackingCode'));
     $piwikTrackingCodeField = new TextareaField('PiwikTrackingCode', $this->owner->fieldLabel('PiwikTrackingCode'));
     $fields->addFieldToTab('Root.SEO', $googleWebmasterCodeField);
     $fields->addFieldToTab('Root.SEO', $googleAnalyticsTrackingCodeField);
     $fields->addFieldToTab('Root.SEO', $googleConversionTrackingCodeField);
     $fields->addFieldToTab('Root.SEO', $piwikTrackingCodeField);
     $facebookLinkField = new TextField('FacebookLink', $this->owner->fieldLabel('FacebookLink'));
     $twitterLinkField = new TextField('TwitterLink', $this->owner->fieldLabel('TwitterLink'));
     $xingLinkField = new TextField('XingLink', $this->owner->fieldLabel('XingLink'));
     $fields->addFieldToTab('Root.SocialMedia', $facebookLinkField);
     $fields->addFieldToTab('Root.SocialMedia', $twitterLinkField);
     $fields->addFieldToTab('Root.SocialMedia', $xingLinkField);
     $translatable = new Translatable();
     $translatable->setOwner($this->owner);
     $translatable->updateCMSFields($fields);
     $localeField = new TextField('CurrentLocale', $this->owner->fieldLabel('CurrentLocale'), i18n::get_locale_name($this->owner->Locale));
     $createButton = new InlineFormAction('createsitetreetranslation', $this->owner->fieldLabel('createsitetreetranslation'));
     $publishButton = new InlineFormAction('publishsitetree', $this->owner->fieldLabel('publishsitetree'));
     $localeField->setReadonly(true);
     $localeField->setDisabled(true);
     $createButton->setRightTitle($this->owner->fieldLabel('createsitetreetranslationDesc'));
     $createButton->includeDefaultJS(false);
     $createButton->addExtraClass('createTranslationButton');
     $publishButton->includeDefaultJS(false);
     $publishButton->addExtraClass('createTranslationButton');
     $fields->addFieldToTab('Root.Translations', $localeField, 'CreateTransHeader');
     $fields->addFieldToTab('Root.Translations', $createButton, 'createtranslation');
     $fields->addFieldToTab('Root.Translations', $publishButton, 'createtranslation');
     $fields->removeByName('createtranslation');
     $this->getCMSFieldsForSilvercart($fields);
 }