public function Field($properties = array()) { $fields = new FieldGroup($this->name); $fields->setID("{$this->name}_Holder"); list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue(); if ($this->value == "") { $countryCode = $this->countryCode; $areaCode = $this->areaCode; $extension = $this->ext; } if ($this->countryCode !== null) { $fields->push(new NumericField($this->name . '[Country]', '+', $countryCode, 4)); } if ($this->areaCode !== null) { $fields->push(new NumericField($this->name . '[Area]', '(', $areaCode, 4)); $fields->push(new NumericField($this->name . '[Number]', ')', $phoneNumber, 10)); } else { $fields->push(new NumericField($this->name . '[Number]', '', $phoneNumber, 10)); } if ($this->ext !== null) { $fields->push(new NumericField($this->name . '[Extension]', 'ext', $extension, 6)); } $description = $this->getDescription(); if ($description) { $fields->getChildren()->First()->setDescription($description); } foreach ($fields as $field) { $field->setDisabled($this->isDisabled()); $field->setReadonly($this->isReadonly()); } return $fields; }
function __construct($controller, $name) { $org_field = null; $current_user = Member::currentUser(); $current_affiliations = $current_user->getCurrentAffiliations(); if (!$current_affiliations) { $org_field = new TextField('Organization', 'Your Organization Name'); } else { if (count($current_affiliations) > 1) { $source = array(); foreach ($current_affiliations as $a) { $org = $a->Organization(); $source[$org->ID] = $org->Name; } $source['0'] = "-- New One --"; $ddl = new DropdownField('OrgID', 'Your Organization', $source); $ddl->setEmptyString('-- Select Your Organization --'); $org_field = new FieldGroup(); $org_field->push($ddl); $org_field->push($txt = new TextField('Organization', '')); $txt->addExtraClass('new-org-name'); } else { $org_field = new TextField('Organization', 'Your Organization Name', $current_user->getOrgName()); } } $fields = new FieldList($org_field, new DropdownField('Industry', 'Your Organization’s Primary Industry', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$industry_options, array('' => '-- Please Select One --'), array('Other' => 'Other Industry (please specify)'))), new TextareaField('OtherIndustry', 'Other Industry'), $org_it_activity = new TextareaField('ITActivity', 'Your Organization’s Primary IT Activity'), new LiteralField('Break', '<hr/>'), new LiteralField('Break', '<p>Your Organization’s Primary Location or Headquarters</p>'), $country = new DropdownField('PrimaryCountry', 'Country', CountryCodes::$iso_3166_countryCodes), new TextField('PrimaryState', 'State / Province / Region'), new TextField('PrimaryCity', 'City'), new DropdownField('OrgSize', 'Your Organization Size (All Branches, Locations, Sites)', DeploymentSurveyOptions::$organization_size_options), new CustomCheckboxSetField('OpenStackInvolvement', 'What best describes your Organization’s involvement with OpenStack?<BR>Select All That Apply', ArrayUtils::AlphaSort(DeploymentSurveyOptions::$openstack_involvement_options))); $org_it_activity->addExtraClass('hidden'); $country->setEmptyString('-- Select One --'); $nextButton = new FormAction('NextStep', ' Next Step '); $actions = new FieldList($nextButton); $validator = new RequiredFields(); Requirements::javascript('surveys/js/deployment_survey_yourorganization_form.js'); parent::__construct($controller, $name, $fields, $actions, $validator); }
public function Field() { $field = new FieldGroup($this->name); $field->setID("{$this->name}_Holder"); list($countryCode, $areaCode, $phoneNumber, $extension) = $this->parseValue(); $hasTitle = false; if ($this->value == "") { $countryCode = $this->countryCode; $areaCode = $this->areaCode; $extension = $this->ext; } if ($this->countryCode !== null) { $field->push(new NumericField($this->name . '[Country]', '+', $countryCode, 4)); } if ($this->areaCode !== null) { $field->push(new NumericField($this->name . '[Area]', '(', $areaCode, 4)); $field->push(new NumericField($this->name . '[Number]', ')', $phoneNumber, 10)); } else { $field->push(new NumericField($this->name . '[Number]', '', $phoneNumber, 10)); } if ($this->ext !== null) { $field->push(new NumericField($this->name . '[Extension]', 'ext', $extension, 6)); } return $field; }
public function Field() { $field = new FieldGroup($this->name); $field->setID("{$this->name}_Holder"); $valueArr = array(); list($valueArr['BankCode'], $valueArr['BranchCode'], $valueArr['AccountNumber'], $valueArr['AccountSuffix']) = explode(" ", $this->value); $valueArr = self::convert_format_nz($valueArr); $field->push(new NumericField($this->name . '[BankCode]', '', $valueArr['BankCode'], 2)); $field->push(new NumericField($this->name . '[BranchCode]', '', $valueArr['BranchCode'], 4)); $field->push(new NumericField($this->name . '[AccountNumber]', '', $valueArr['AccountNumber'], 8)); $field->push(new NumericField($this->name . '[AccountSuffix]', '', $valueArr['AccountSuffix'], 3)); return $field; }
public function Field() { $field = new FieldGroup($this->name); $field->setID("{$this->name}_Holder"); $valueArr = $this->valueArr; $valueArr = self::convert_format_nz($valueArr); $field->push($n1 = new NumericField($this->name . '[BankCode]', '', $valueArr['BankCode'], 2)); $field->push($n2 = new NumericField($this->name . '[BranchCode]', '', $valueArr['BranchCode'], 4)); $field->push($n3 = new NumericField($this->name . '[AccountNumber]', '', $valueArr['AccountNumber'], 8)); $field->push($n4 = new NumericField($this->name . '[AccountSuffix]', '', $valueArr['AccountSuffix'], 3)); if ($this->tabIndex) { $n1->setTabIndex($this->getTabIndex()); $n2->setTabIndex($this->getTabIndex() + 1); $n3->setTabIndex($this->getTabIndex() + 2); $n4->setTabIndex($this->getTabIndex() + 3); } return $field; }
public function getSettingsFields() { $dataTypes = $this->getAvailableTypes(); $reportable = $this->getReportableFields(); $converted = array(); foreach ($reportable as $k => $v) { $converted[$this->dottedFieldToUnique($k)] = $v; } $dataTypes = array_merge(array('' => ''), $dataTypes); $types = new MultiValueDropdownField('DataTypes', _t('AdvancedReport.DATA_TYPES', 'Data types'), $dataTypes); $fieldsGroup = new FieldGroup('Fields', $reportFieldsSelect = new MultiValueDropdownField('ReportFields', _t('AdvancedReport.REPORT_FIELDS', 'Report Fields'), $reportable)); $fieldsGroup->push(new MultiValueTextField('ReportHeaders', _t('AdvancedReport.HEADERS', 'Header labels'))); $fieldsGroup->addExtraClass('reportMultiField'); $reportFieldsSelect->addExtraClass('reportFieldsSelection'); $fieldsGroup->setName('FieldsGroup'); $fieldsGroup->addExtraClass('advanced-report-fields dropdown'); $conditions = new FieldGroup('Conditions', new MultiValueDropdownField('ConditionFields', _t('AdvancedReport.CONDITION_FIELDS', 'Condition Fields'), $reportable), new MultiValueDropdownField('ConditionOps', _t('AdvancedReport.CONDITION_OPERATIONS', 'Op'), $this->config()->allowed_conditions), new MultiValueTextField('ConditionValues', _t('AdvancedReport.CONDITION_VALUES', 'Value'))); $conditions->setName('ConditionsGroup'); $conditions->addExtraClass('dropdown'); // define the group for the sort field $sortGroup = new FieldGroup('Sort', new MultiValueDropdownField('SortBy', _t('AdvancedReport.SORTED_BY', 'Sorted By'), $reportable), new MultiValueDropdownField('SortDir', _t('AdvancedReport.SORT_DIRECTION', 'Sort Direction'), array('ASC' => _t('AdvancedReport.ASC', 'Ascending'), 'DESC' => _t('AdvancedReport.DESC', 'Descending')))); $sortGroup->setName('SortGroup'); $sortGroup->addExtraClass('dropdown'); // build a list of the formatters $formatters = ClassInfo::implementorsOf('ReportFieldFormatter'); $fmtrs = array(); foreach ($formatters as $formatterClass) { $formatter = new $formatterClass(); $fmtrs[$formatterClass] = $formatter->label(); } // define the group for the custom field formatters $fieldFormattingGroup = new FieldGroup(_t('AdvancedReport.FORMAT_FIELDS', 'Custom field formatting'), new MultiValueDropdownField('FieldFormattingField', _t('AdvancedReport.FIELDFORMATTING', 'Field'), $converted), new MultiValueDropdownField('FieldFormattingFormatter', _t('AdvancedReport.FIELDFORMATTINGFORMATTER', 'Formatter'), $fmtrs)); $fieldFormattingGroup->setName('FieldFormattingGroup'); $fieldFormattingGroup->addExtraClass('dropdown'); // assemble the fieldlist $fields = new FieldList(new TextField('Title', _t('AdvancedReport.TITLE', 'Title')), new TextareaField('Description', _t('AdvancedReport.DESCRIPTION', 'Description')), $types, $fieldsGroup, $conditions, new KeyValueField('ReportParams', _t('AdvancedReport.REPORT_PARAMETERS', 'Default report parameters')), $sortGroup, new MultiValueDropdownField('NumericSort', _t('AdvancedReport.SORT_NUMERICALLY', 'Sort these fields numerically'), $reportable), DropdownField::create('PaginateBy')->setTitle(_t('AdvancedReport.PAGINATE_BY', 'Paginate By'))->setSource($reportable)->setHasEmptyDefault(true), TextField::create('PageHeader')->setTitle(_t('AdvancedReport.HEADER_TEXT', 'Header text'))->setDescription(_t('AdvancedReport.USE_NAME_FOR_PAGE_NAME', 'use $name for the page name'))->setValue('$name'), new MultiValueDropdownField('AddInRows', _t('AdvancedReport.ADD_IN_ROWS', 'Add these columns for each row'), $converted), new MultiValueDropdownField('AddCols', _t('AdvancedReport.ADD_IN_ROWS', 'Provide totals for these columns'), $converted), $fieldFormattingGroup, new MultiValueDropdownField('ClearColumns', _t('AdvancedReport.CLEARED_COLS', '"Cleared" columns'), $converted)); if ($this->config()->allow_grouping) { // GroupBy $groupingGroup = new FieldGroup('Grouping', new MultiValueDropdownField('GroupBy', _t('AdvancedReport.GROUPBY_FIELDS', 'Group by fields'), $reportable), new MultiValueDropdownField('SumFields', _t('AdvancedReport.SUM_FIELDS', 'SUM fields'), $reportable)); $groupingGroup->addExtraClass('dropdown'); $fields->insertAfter($groupingGroup, 'ConditionsGroup'); } if ($this->hasMethod('updateReportFields')) { Deprecation::notice('3.0', 'The updateReportFields method is deprecated, instead overload getSettingsFields'); $this->updateReportFields($fields); } $this->extend('updateSettingsFields', $fields); return $fields; }
public function getHTMLFragments($gridField) { if (!$this->checkDataType($gridField->getList())) { return; } $forTemplate = new ArrayData(array()); $forTemplate->Fields = new ArrayList(); $columns = $gridField->getColumns(); $filterArguments = $gridField->State->GridFieldFilterHeader->Columns->toArray(); $currentColumn = 0; foreach ($columns as $columnField) { $currentColumn++; $metadata = $gridField->getColumnMetadata($columnField); $title = $metadata['title']; $fields = new FieldGroup(); if ($title && $gridField->getList()->canFilterBy($columnField)) { $value = ''; if (isset($filterArguments[$columnField])) { $value = $filterArguments[$columnField]; } $field = new TextField('filter[' . $gridField->getName() . '][' . $columnField . ']', '', $value); $field->addExtraClass('ss-gridfield-sort'); $field->addExtraClass('no-change-track'); $field->setAttribute('placeholder', _t('GridField.FilterBy', "Filter by ") . _t('GridField.' . $metadata['title'], $metadata['title'])); $fields->push($field); $fields->push(GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-reset')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)); } if ($currentColumn == count($columns)) { $fields->push(GridField_FormAction::create($gridField, 'filter', false, 'filter', null)->addExtraClass('ss-gridfield-button-filter')->setAttribute('title', _t('GridField.Filter', "Filter"))->setAttribute('id', 'action_filter_' . $gridField->getModelClass() . '_' . $columnField)); $fields->push(GridField_FormAction::create($gridField, 'reset', false, 'reset', null)->addExtraClass('ss-gridfield-button-close')->setAttribute('title', _t('GridField.ResetFilter', "Reset"))->setAttribute('id', 'action_reset_' . $gridField->getModelClass() . '_' . $columnField)); $fields->addExtraClass('filter-buttons'); $fields->addExtraClass('no-change-track'); } $forTemplate->Fields->push($fields); } return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row')); }
/** * Security tab for folders */ public function updateCMSFields(FieldSet &$fields) { // Only modify folder objects with parent nodes if (!$this->owner instanceof Folder || !$this->owner->ID) { return; } // Only allow ADMIN and SECURE_FILE_SETTINGS members to edit these options if (!Permission::checkMember(Member::currentUser(), array('ADMIN', 'SECURE_FILE_SETTINGS'))) { return; } $secureFilesTab = $fields->findOrMakeTab('Root.' . _t('SecureFiles.SECUREFILETABNAME', 'Security')); $EnableSecurityHolder = new FieldGroup(); $EnableSecurityHolder->addExtraClass('securityFieldHolder'); if ($this->InheritSecured()) { $EnableSecurityField = new ReadonlyField('InheritSecurity', '', _t('SecureFiles.INHERITED', 'This folder is inheriting security settings from a parent folder.')); $EnableSecurityField->addExtraClass('prependLock'); } else { $EnableSecurityField = new CheckboxField('Secured', _t('SecureFiles.SECUREFOLDER', 'Folder is secure.')); } $secureFilesTab->push(new HeaderField(_t('SecureFiles.FOLDERSECURITY', 'Folder Security'))); $EnableSecurityHolder->push($EnableSecurityField); $secureFilesTab->push($EnableSecurityHolder); }
/** * Returns a FieldList with which to create the CMS editing form. * You can use the extend() method of FieldList to create customised forms for your other * data objects. * * @uses getReportField() to render a table, or similar field for the report. This * method should be defined on the SS_Report subclasses. * * @return FieldList */ function getCMSFields() { $fields = new FieldList( new LiteralField( 'ReportTitle', "<h3>{$this->title()}</h3>" ) ); if($this->description()) $fields->push( new LiteralField('ReportDescription', "<p>" . $this->description() . "</p>")); // Add search fields is available if($params = $this->parameterFields()) { $filters = new FieldGroup('Filters'); foreach($params as $param) { if ($param instanceof HiddenField) $fields->push($param); else $filters->push($param); } $fields->push($filters); // Add a search button $fields->push(new FormAction('updatereport', 'Filter')); } $fields->push($this->getReportField()); $this->extend('updateCMSFields', $fields); return $fields; }
/** * Create form fields to represent all of the properties on the {@link Omnipay\Common\CreditCard} object. * The form fields are split up into relevent sections to help with adding/removing fields as needed. * * @return FieldList */ protected function getCreditCardFields() { $fields = new FieldList(); $tabindex = 1; // Create personal detail fields $firstNameTextField = new TextField('FirstName', _t('OmnipayableForm.FIRSTNAME', 'First name')); $firstNameTextField->setAttribute('tabindex', $tabindex++); $lastNameTextField = new TextField('LastName', _t('OmnipayableForm.LASTNAME', 'Last name')); $lastNameTextField->setAttribute('tabindex', $tabindex++); $companyTextField = new TextField('Company', _t('OmnipayableForm.COMPANY', 'Company')); $companyTextField->setAttribute('tabindex', $tabindex++); $emailEmailField = new EmailField('Email', _t('OmnipayableForm.EMAIL', 'Email')); $emailEmailField->setAttribute('tabindex', $tabindex++); // Create personal details group $personalFieldGroup = new FieldGroup(); $personalFieldGroup->setName('PersonalDetails'); $personalFieldGroup->setTitle(_t('OmnipayableForm.PERSONALDETAILS', 'Personal Detials')); // Add basic fields to personal details group $personalFieldGroup->push($firstNameTextField); $personalFieldGroup->push($lastNameTextField); $personalFieldGroup->push($companyTextField); $personalFieldGroup->push($emailEmailField); // Add personal details group to fields $fields->push($personalFieldGroup); // Create credit card detail fields $numberCreditCardField = new CreditCardField('Number', _t('OmnipayableForm.NUMBER', 'Card number')); $numberCreditCardField->setAttribute('tabindex', $tabindex++); $cvvTextField = new TextField('Cvv', _t('OmnipayableForm.CVV', 'Security number')); $cvvTextField->setAttribute('tabindex', $tabindex += 3); $expiryMonthDropdownField = new DropdownField('ExpiryMonth', _t('OmnipayableForm.EXPIRYMONTH', 'Expiry month'), $this->getMonths()); $expiryMonthDropdownField->setAttribute('tabindex', $tabindex++); $expiryMonthDropdownField->setHasEmptyDefault(true); $expiryYearDropdownField = new DropdownField('ExpiryYear', _t('OmnipayableForm.EXPIRYYEAR', 'Expiry year'), $this->getYears(20)); $expiryYearDropdownField->setAttribute('tabindex', $tabindex++); $expiryYearDropdownField->setHasEmptyDefault(true); $startMonthDropdownField = new DropdownField('StartMonth', _t('OmnipayableForm.STARTMONTH', 'Start month'), $this->getMonths()); $startMonthDropdownField->setAttribute('tabindex', $tabindex++); $startMonthDropdownField->setHasEmptyDefault(true); $startYearDropdownField = new DropdownField('StartYear', _t('OmnipayableForm.STARTYEAR', 'Start year'), $this->getYears(-20)); $startYearDropdownField->setAttribute('tabindex', $tabindex++); $startYearDropdownField->setHasEmptyDefault(true); $issueNumberTextField = new TextField('IssueNumber', _t('OmnipayableForm.ISSUENUMBER', 'Issue number')); $issueNumberTextField->setAttribute('tabindex', $tabindex++); $typeDropdownField = new DropdownField('Type', _t('OmnipayableForm.TYPE', 'Card type'), $this->getCreditCardTypes()); $typeDropdownField->setAttribute('tabindex', $tabindex++); $typeDropdownField->setHasEmptyDefault(true); $expiryDateFieldGroup = new FieldGroup(); $expiryDateFieldGroup->push($expiryMonthDropdownField); $expiryDateFieldGroup->push($expiryYearDropdownField); $startDateFieldGroup = new FieldGroup(); $startDateFieldGroup->push($startMonthDropdownField); $startDateFieldGroup->push($startYearDropdownField); // Create credit card details group $creditCardFieldGroup = new FieldGroup(); $creditCardFieldGroup->setName('CardDetails'); $creditCardFieldGroup->setTitle(_t('OmnipayableForm.CREDITCARDDETAILS', 'Card Detials')); // Add credit card fields to credit card details group $creditCardFieldGroup->push($numberCreditCardField); $creditCardFieldGroup->push($cvvTextField); $creditCardFieldGroup->push($expiryDateFieldGroup); $creditCardFieldGroup->push($startDateFieldGroup); $creditCardFieldGroup->push($issueNumberTextField); $creditCardFieldGroup->push($typeDropdownField); // Add credit card details group to fields $fields->push($creditCardFieldGroup); // Create billing address fields $billingAddress1TextField = new TextField('BillingAddress1', _t('OmnipayableForm.BILLINGADDRESS1', 'Address 1')); $billingAddress1TextField->setAttribute('tabindex', $tabindex++); $billingAddress2TextField = new TextField('BillingAddress2', _t('OmnipayableForm.BILLINGADDRESS2', 'Address 2')); $billingAddress2TextField->setAttribute('tabindex', $tabindex++); $billingCity = new TextField('BillingCity', _t('OmnipayableForm.BILLINGCITY', 'City')); $billingCity->setAttribute('tabindex', $tabindex++); $billingPostcode = new TextField('BillingPostcode', _t('OmnipayableForm.BILLINGPOSTCODE', 'Postcode')); $billingPostcode->setAttribute('tabindex', $tabindex++); $billingState = new TextField('BillingState', _t('OmnipayableForm.BILLINGSTATE', 'State')); $billingState->setAttribute('tabindex', $tabindex++); $billingCountry = new CountryDropdownField('BillingCountry', _t('OmnipayableForm.BILLINGCOUNTRY', 'Country')); $billingCountry->setAttribute('tabindex', $tabindex++); $billingPhone = new PhoneNumberField('BillingPhone', _t('OmnipayableForm.BILLINGPHONE', 'Phone')); $billingPhone->setAttribute('tabindex', $tabindex++); // Create billing details group $billingFieldGroup = new FieldGroup(); $billingFieldGroup->setName('BillingAddress'); $billingFieldGroup->setTitle(_t('OmnipayableForm.BILLING', 'Billing Address')); // Add billiing fields to billing group $billingFieldGroup->push($billingAddress1TextField); $billingFieldGroup->push($billingAddress2TextField); $billingFieldGroup->push($billingCity); $billingFieldGroup->push($billingPostcode); $billingFieldGroup->push($billingState); $billingFieldGroup->push($billingCountry); $billingFieldGroup->push($billingPhone); // Add billing details group to fields $fields->push($billingFieldGroup); // Create shipping address fields $shippingAddress1TextField = new TextField('ShippingAddress1', _t('OmnipayableForm.SHIPPINGADDRESS1', 'Address 1')); $shippingAddress1TextField->setAttribute('tabindex', $tabindex++); $shippingAddress2TextField = new TextField('ShippingAddress2', _t('OmnipayableForm.SHIPPINGADDRESS2', 'Address 2')); $shippingAddress2TextField->setAttribute('tabindex', $tabindex++); $shippingCity = new TextField('ShippingCity', _t('OmnipayableForm.SHIPPINGCITY', 'City')); $shippingCity->setAttribute('tabindex', $tabindex++); $shippingPostcode = new TextField('ShippingPostcode', _t('OmnipayableForm.SHIPPINGPOSTCODE', 'Postcode')); $shippingPostcode->setAttribute('tabindex', $tabindex++); $shippingState = new TextField('ShippingState', _t('OmnipayableForm.SHIPPINGSTATE', 'State')); $shippingState->setAttribute('tabindex', $tabindex++); $shippingCountry = new CountryDropdownField('ShippingCountry', _t('OmnipayableForm.SHIPPINGCOUNTRY', 'Country')); $shippingCountry->setAttribute('tabindex', $tabindex++); $shippingPhone = new PhoneNumberField('ShippingPhone', _t('OmnipayableForm.SHIPPINGPHONE', 'Phone')); $shippingPhone->setAttribute('tabindex', $tabindex++); // Create shipping details group $shippingFieldGroup = new FieldGroup(); $shippingFieldGroup->setName('ShippingAddress'); $shippingFieldGroup->setTitle(_t('OmnipayableForm.SHIPPING', 'Shipping Address')); // Add billiing fields to shipping group $shippingFieldGroup->push($shippingAddress1TextField); $shippingFieldGroup->push($shippingAddress2TextField); $shippingFieldGroup->push($shippingCity); $shippingFieldGroup->push($shippingPostcode); $shippingFieldGroup->push($shippingState); $shippingFieldGroup->push($shippingCountry); $shippingFieldGroup->push($shippingPhone); // Add shipping details group to fields $fields->push($shippingFieldGroup); return $fields; }