public function __construct($name, $title = null, $value = null, $form = null)
 {
     $allowed_types = $this->stat('allowed_types');
     $field_types = $this->stat('field_types');
     if (empty($allowed_types)) {
         $allowed_types = array_keys($field_types);
     }
     $field = new DropdownField("{$name}[Type]", '', array_combine($allowed_types, $allowed_types));
     $field->setEmptyString('Please choose the Link Type');
     $this->composite_fields['Type'] = $field;
     foreach ($allowed_types as $type) {
         $def = $field_types[$type];
         $field_name = "{$name}[{$type}]";
         switch ($def['field']) {
             case 'TreeDropdownField':
                 $field = new TreeDropdownField($field_name, '', 'SiteTree', 'ID', 'Title');
                 break;
             default:
                 $field = new TextField($field_name, '');
                 break;
         }
         $field->setDescription($def['description']);
         $field->addExtraClass('FlexiLinkCompositeField');
         $this->composite_fields[$type] = $field;
     }
     $this->setForm($form);
     parent::__construct($name, $title, $value, $form);
 }
예제 #2
0
 function __construct($controller, $name, $use_actions = true)
 {
     $fields = new FieldList();
     //main info
     $fields->push(new TextField('title', 'Title'));
     $fields->push(new TextField('url', 'Url'));
     $categoryField = new TextField('event_category', 'Category');
     $categoryField->setAttribute('class', 'event-category-autocomplete text');
     $fields->push($categoryField);
     //location
     $fields->push(new TextField('location', 'Location'));
     //duration
     $fields->push($start_date = new TextField('start_date', 'Start Date'));
     $fields->push($end_date = new TextField('end_date', 'End Date'));
     $start_date->addExtraClass('date');
     $end_date->addExtraClass('date');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveEvent', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'location'), new RequiredFields('start_date', 'end_date')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 /**
  * @return Comosite FieldSet with Categorys and Items
  */
 function getCompositeField()
 {
     //create new composite field group for each category
     $oCatFieldSet = new CompositeField();
     // Set the field group ID
     $oCatFieldSet->setID('Cat' . $this->ID);
     $oCatFieldSet->addExtraClass('category');
     //create new composite field group for each category
     $oCatField = new TextField($this->ID . '_' . $this->FieldName, $this->Title, null, null);
     $oCatField->addExtraClass('category-field');
     //Add Category Percentage Field to the Form
     $oCatFieldSet->push($oCatField);
     if ($this->Description) {
         $oCatDescField = new LiteralField($this->ID . '_Description', '<p class="category-field-desc">' . $this->Description . '</p>');
         $oCatDescField->addExtraClass('category-field');
         $oCatFieldSet->push($oCatDescField);
     }
     //Add item Composite Field to this Composite Field
     //now get all of the items matched with this category
     $oFormCategoryItems = self::FormCategoryItems();
     foreach ($oFormCategoryItems as $item) {
         $oCatFieldSet->push($item->getFormField());
     }
     return $oCatFieldSet;
 }
    function __construct($controller, $name)
    {
        $Name = new TextField('Name', 'Your name');
        $Phone = new TextField('Phone', 'Your phone number');
        $Email = new TextField('Email', 'Your email');
        $Subject = new TextField('Subject', 'Subject');
        $Message = new TextareaField('Message', 'Your message', '10', '45');
        $Name->addExtraClass('Required');
        $Email->addExtraClass('Required');
        $Message->addExtraClass('Required');
        $messageFields = new CompositeField($Name, $Phone, $Email, $Subject, $Message);
        $fields = new FieldSet($messageFields);
        $actions = new FieldSet(new FormAction('processMessage', 'send'));
        Requirements::customScript('
			jQuery(document).ready(function() {
				
				jQuery("#ContactForm_ContactForm_Name").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#ContactForm_ContactForm_Email").addClass("validate[required,custom[email]] text-input");
				jQuery("#ContactForm_ContactForm_Message").addClass("validate[required,length[6,300]] text-input");
				
				jQuery("#ContactForm_ContactForm").validationEngine()
				
			});
		');
        parent::__construct($controller, $name, $fields, $actions);
    }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('Title');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('ParentProcessID');
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField($title = new TextField('Title', 'Title')));
        $title->addExtraClass('process-noborder');
        $processSteps->addExtraClass('process-step');
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField(new GridField('ProcessInfo', 'Information for this case', $this->ProcessInfo(), GridFieldConfig_RecordViewer::create())));
        $processes = Process::get();
        if ($processes) {
            $fields->insertAfter($inner = new CompositeField(new LiteralField('ExplainStop', '<label class="right">This must be set after you create a process</label>'), $processesOptions = new DropdownField('ParentProcessID', 'Process', $processes->map('ID', 'Title'))), 'Title');
            $inner->addExtraClass('message special');
        }
        $processSteps->addExtraClass('process-step');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">0.1</span><span class="arrow"></span>
					<span class="title">Case details</span>
				</span>
			</h3>'), 'Title');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">0.2</span><span class="arrow"></span>
					<span class="title">Associated Information Pieces</span>
				</span>
			</h3>'), 'ProcessInfo');
        return $fields;
    }
 /**
  * 
  * @param GridField $gridField
  * @return string - HTML
  */
 public function getHTMLFragments($gridField)
 {
     $searchState = $gridField->State->GridFieldSearchRelation;
     $dataClass = $gridField->getList()->dataClass();
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     $value = $this->findSingleEntry($gridField, $searchFields, $searchState, $dataClass);
     $searchField = new TextField('gridfield_relationsearch', _t('GridField.RelationSearch', "Relation search"), $value);
     // Apparently the data-* needs to be double qouted for the jQuery.meta data plugin
     $searchField->setAttribute('data-search-url', '\'' . Controller::join_links($gridField->Link('search') . '\''));
     $searchField->setAttribute('placeholder', $this->getPlaceholderText($dataClass));
     $searchField->addExtraClass('relation-search no-change-track');
     $findAction = new GridField_FormAction($gridField, 'gridfield_relationfind', _t('GridField.Find', "Find"), 'find', 'find');
     $findAction->setAttribute('data-icon', 'relationfind');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addto', 'addto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     // If an object is not found, disable the action
     if (!is_int($gridField->State->GridFieldAddRelation)) {
         $addAction->setReadonly(true);
     }
     $forTemplate->Fields->push($searchField);
     $forTemplate->Fields->push($findAction);
     $forTemplate->Fields->push($addAction);
     return array($this->targetFragment => $forTemplate->renderWith($this->itemClass));
 }
 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);
 }
 function __construct($controller, $name)
 {
     $fields = new FieldList(array($t1 = new TextField('ExternalOrderId', 'Eventbrite Order #'), $checkbox = new CheckboxField('SharedContactInfo', 'Allow to share contact info?')));
     $t1->setAttribute('placeholder', 'Enter your Eventbrite order #');
     $t1->addExtraClass('event-brite-order-number');
     $attendees = Session::get('attendees');
     if (count($attendees) > 0) {
         $t1->setValue(Session::get('ExternalOrderId'));
         $t1->setReadonly(true);
         $checkbox->setValue(intval(Session::get('SharedContactInfo')) === 1);
         $fields->add(new LiteralField('ctrl1', 'Current Order has following registered attendees, please select one:'));
         $options = array();
         foreach ($attendees as $attendee) {
             $ticket_external_id = intval($attendee['ticket_class_id']);
             $ticket_type = SummitTicketType::get()->filter('ExternalId', $ticket_external_id)->first();
             if (is_null($ticket_type)) {
                 continue;
             }
             $options[$attendee['id']] = $attendee['profile']['name'] . ' (' . $ticket_type->Name . ')';
         }
         $attendees_ctrl = new OptionSetField('SelectedAttendee', '', $options);
         $fields->add($attendees_ctrl);
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn_clear = new FormAction('clearSummitAttendeeInfo', 'Clear'), $btn = new FormAction('saveSummitAttendeeInfo', 'Done'));
         $btn->addExtraClass('btn btn-default active');
         $btn_clear->addExtraClass('btn btn-danger active');
     } else {
         $validator = new RequiredFields(array('ExternalOrderId'));
         // Create action
         $actions = new FieldList($btn = new FormAction('saveSummitAttendeeInfo', 'Get Order'));
         $btn->addExtraClass('btn btn-default active');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 function __construct($controller, $name, $speakerID, $use_actions = true)
 {
     $fields = new FieldList();
     //point of contact
     $speakerIDfield = new HiddenField('speaker_id');
     $speakerIDfield->setValue($speakerID);
     $fields->push($speakerIDfield);
     $fields->push(new TextField('org_name', 'Name of Organizer'));
     $fields->push(new EmailField('org_email', 'Email'));
     $fields->push(new TextField('event_name', 'Event'));
     $fields->push(new TextField('event_format', 'Format/Length'));
     $fields->push(new TextField('event_attendance', 'Expected Attendance (number)'));
     $fields->push(new TextField('event_date', 'Date of Event'));
     $fields->push(new TextField('event_location', 'Location'));
     $fields->push(new TextField('event_topic', 'Topic(s)'));
     $request = new HtmlEditorField('general_request', 'General Request');
     $request->setRows(10);
     $fields->push($request);
     $sec_field = new TextField('field_98438688', 'field_98438688');
     $sec_field->addExtraClass('honey');
     $fields->push($sec_field);
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('sendSpeakerEmail', 'Send'));
     }
     parent::__construct($controller, $name, $fields, $actions);
 }
 function RegistrationForm()
 {
     // Name Set
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('Surname', "Last Name");
     // Email Addresses
     $PrimaryEmailField = new TextField('Email', "Primary Email Address");
     // 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');
     $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest');
     $StatementOfInterestField->addExtraClass('autocompleteoff');
     $affiliations = new AffiliationField('Affiliations', 'Affiliations');
     $affiliations->setMode('local');
     $fields = new FieldList($FirstNameField, $LastNameField, new LiteralField('break', '<hr/>'), $PrimaryEmailField, new LiteralField('instructions', '<p>This will also be your login name.</p>'), 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/>'), $affiliations, $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/>'), 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')));
     $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));
     }
     $AdressField = new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode'));
     $fields->push($AdressField);
     $label = _t('Addressable.COUNTRY', 'Country');
     if (is_array($this->allowedCountries)) {
         $countryField = new DropdownField('Country', $label, $this->allowedCountries);
         $countryField->addExtraClass('chzn-select');
         $countryField->setEmptyString('-- Select One --');
         $fields->push($countryField);
     } elseif (!is_string($this->allowedCountries)) {
         $countryField = new CountryDropdownField('Country', $label);
         $countryField->setEmptyString('-- Select One --');
         $countryField->addExtraClass('chzn-select');
         $fields->push($countryField);
     }
     $fields->push(new LiteralField('break', '<hr/>'));
     $fields->push(new ConfirmedPasswordField('Password', 'Password'));
     $fields->push(new HiddenField('MembershipType', 'MembershipType', 'foundation'));
     $request = Controller::curr()->getRequest();
     $back_url = $request->getVar('BackURL');
     if (!empty($back_url)) {
         $fields->push(new HiddenField('BackURL', 'BackURL', $back_url));
     }
     $actions = new FieldList(new FormAction('doRegister', 'Submit My Application'));
     $validator = new Member_Validator('FirstName', 'Surname', 'Email', 'StatementOfInterest', 'Address', 'City', 'Country', 'Password');
     $form = new HoneyPotForm($this, 'RegistrationForm', $fields, $actions, $validator);
     if ($data = Session::get("FormInfo.{$form->FormName()}.data")) {
         if (isset($data['HiddenAffiliations'])) {
             $affiliations->setValue($data['HiddenAffiliations']);
         }
         return $form->loadDataFrom($data);
     }
     return $form;
 }
 function __construct($controller, $name, $use_actions = true)
 {
     $fields = new FieldList();
     //point of contact
     $fields->push($point_of_contact_name = new TextField('point_of_contact_name', 'Name'));
     $fields->push($point_of_contact_email = new EmailField('point_of_contact_email', 'Email'));
     //main info
     $fields->push($title = new TextField('title', 'Title'));
     $fields->push($url = new TextField('url', 'Url'));
     $fields->push(new CheckboxField('is_coa_needed', 'Is COA needed?'));
     $fields->push($ddl_type = new DropdownField('job_type', 'Job Type', JobType::get()->sort("Type")->map("ID", "Type")));
     $ddl_type->setEmptyString("--SELECT A JOB TYPE --");
     $fields->push($description = new HtmlEditorField('description', 'Description'));
     $fields->push($instructions = new HtmlEditorField('instructions', 'Instructions To Apply'));
     $fields->push($expiration_date = new TextField('expiration_date', 'Expiration Date'));
     $fields->push($company = new CompanyField('company', 'Company'));
     $point_of_contact_name->addExtraClass('job_control');
     $point_of_contact_email->addExtraClass('job_control');
     $title->addExtraClass('job_control');
     $url->addExtraClass('job_control');
     $description->addExtraClass('job_control');
     $instructions->addExtraClass('job_control');
     $expiration_date->addExtraClass('job_control');
     $company->addExtraClass('job_control');
     //location
     $ddl_locations = new DropdownField('location_type', 'Location Type', array('N/A' => 'N/A', 'Remote' => 'Remote', 'Various' => 'Add a Location'));
     $ddl_locations->addExtraClass('location_type');
     $ddl_locations->addExtraClass('job_control');
     $fields->push($ddl_locations);
     $fields->push($city = new TextField('city', 'City'));
     $fields->push($state = new TextField('state', 'State'));
     $fields->push($country = new CountryDropdownField('country', 'Country'));
     $city->addExtraClass('physical_location');
     $state->addExtraClass('physical_location');
     $country->addExtraClass('physical_location');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveJobRegistrationRequest', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule([new HtmlPurifierRequiredValidator('title', 'instructions', 'description'), new RequiredFields('job_type', 'point_of_contact_name', 'point_of_contact_email')]);
     $this->addExtraClass('job-registration-form');
     $this->addExtraClass('input-form');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
예제 #12
0
    /**
     * @param Controller $controller
     * @param String     $name
     * @param FieldList   $fields
     * @param FieldList   $actions
     * @param null       $validator
     */
    function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null)
    {
        // Guard against automated spam registrations by optionally adding a field
        // that is supposed to stay blank (and is hidden from most humans).
        $fields->push($honey = new TextField(self::FieldName, self::FieldName));
        $honey->addExtraClass('honey');
        $css = <<<CSS
.honey {
\tposition: absolute; left: -9999px
}
CSS;
        Requirements::customCSS($css, 'honey_css');
        parent::__construct($controller, $name, $fields, $actions, $validator);
    }
 /**
  * Builds the entry form so the user can choose what to export.
  */
 function ExportForm()
 {
     $fields = new FieldList();
     // Display available yml files so we can re-export easily.
     $ymlDest = BASE_PATH . '/' . TestDataController::get_data_dir();
     $existingFiles = scandir($ymlDest);
     $ymlFiles = array();
     foreach ($existingFiles as $file) {
         if (preg_match("/.*\\.yml/", $file)) {
             $ymlFiles[$file] = $file;
         }
     }
     if ($ymlFiles) {
         $fields->push(new DropdownField('Reexport', 'Reexport to file (will override any other setting): ', $ymlFiles, '', null, '-- choose file --'));
     }
     // Get the list of available DataObjects
     $dataObjectNames = ClassInfo::subclassesFor('DataObject');
     unset($dataObjectNames['DataObject']);
     sort($dataObjectNames);
     foreach ($dataObjectNames as $dataObjectName) {
         // Skip test only classes.
         $class = singleton($dataObjectName);
         if ($class instanceof TestOnly) {
             continue;
         }
         // Skip testdata internal class
         if ($class instanceof TestDataTag) {
             continue;
         }
         // 	Create a checkbox for including this object in the export file
         $count = $class::get()->Count();
         $fields->push($class = new CheckboxField("Class[{$dataObjectName}]", $dataObjectName . " ({$count})"));
         $class->addExtraClass('class-field');
         // 	Create an ID range selection input
         $fields->push($range = new TextField("Range[{$dataObjectName}]", ''));
         $range->addExtraClass('range-field');
     }
     // Create the "traverse relations" option - whether it should automatically include relation objects even if not explicitly ticked.
     $fields->push(new CheckboxField('TraverseRelations', 'Traverse relations (implicitly includes objects, for example pulls Groups for Members): ', 1));
     // Create the option to include real files.
     $path = BASE_PATH . '/' . TestDataController::get_data_dir();
     $fields->push(new CheckboxField('IncludeFiles', "Copy real files (into {$path}files)", 0));
     // Create file name input field
     $fields->push(new TextField('FileName', 'Name of the output YML file: ', 'output.yml'));
     // Create actions for the form
     $actions = new FieldList(new FormAction("export", "Export"));
     $form = new Form($this, "ExportForm", $fields, $actions);
     $form->setFormAction(Director::baseURL() . 'dev/data/export/TestDataExporter/ExportForm');
     return $form;
 }
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('ProcessInfo');
        $fields->removeByName('StopStageID');
        $fields->removeByName('StopButton');
        $fields->removeByName('ContinueButton');
        $fields->removeByName('DecisionPoint');
        $fields->removeByName('CaseFinal');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
			<span class="step-label">
				<span class="flyout">3</span><span class="arrow"></span>
				<span class="title">Stage Settings</span>
			</span>
		</h3>'), 'Title');
        $caseFinalMap = ProcessCase::get()->filter(array('ParentProcessID' => $this->ParentID))->map("ID", "Title")->toArray();
        asort($caseFinalMap);
        $case = ListboxField::create('CaseFinal', 'Final step for these Cases')->setMultiple(true)->setSource($caseFinalMap)->setAttribute('data-placeholder', _t('ProcessAdmin.Cases', 'Cases', 'Placeholder text for a dropdown'));
        $fields->insertAfter($case, 'Title');
        $fields->insertAfter($group = new CompositeField($label = new LabelField('switchLabel', 'Act as Decision Point'), new CheckboxField('DecisionPoint', '')), 'ParentID');
        $group->addExtraClass("field special process-noborder");
        $label->addExtraClass("left");
        $fields->dataFieldByName('Content')->setRows(10);
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p></p>'));
            $fields->addFieldToTab('Root.Main', $processInfo = new CompositeField($grid = new GridField('ProcessInfo', 'Information for this stage', $this->ProcessInfo()->sort(array('TypeID' => 'ASC', 'ProcessCaseID' => 'ASC', 'LinksToAnotherStageID' => 'ASC')), $gridConfig = GridFieldConfig_RelationEditor::create())));
            $gridConfig->addComponent(new GridFieldSortableRows('Order'));
            $processInfo->addExtraClass('process-spacing');
            $grid->addExtraClass('toggle-grid');
        } else {
            $fields->addFieldToTab('Root.Main', new LiteralField('SaveRecord', '<p class="message info">Save this stage to add info</p>'));
        }
        $fields->insertBefore(new LiteralField('StageTitleInfo', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">4</span><span class="arrow"></span>
					<span class="title">Information</span>
				</span>
			</h3>'), 'SaveRecord');
        $stopStage = ProcessStopStage::get();
        if ($stopStage) {
            $fields->insertBefore($inner = new CompositeField(new LiteralField('Decision', '<h3>Decision Point</h3>'), new LiteralField('ExplainStop', '<label class="right">Choose a stop stage if you would like this stage to act as a decision point</label>'), $stop = new DropdownField('StopStageID', 'Stop Stage', $stopStage->map('ID', 'Title')), $continue = new TextField('ContinueButton', 'Button: Continue (e.g. "Yes")'), new TextField('StopButton', 'Button: Stop (e.g. "No")')), 'ProcessInfo');
            $stop->setEmptyString('No stop after this stage');
            $inner->addExtraClass('message special toggle-decide');
            $continue->addExtraClass('process-noborder');
            $stop->addExtraClass('process-noborder');
        }
        return $fields;
    }
 /**
  * Don't pass $form in by reference, as doing so and adding a field creates both a div and an 
  * input with identical IDs - which is both invalid HTML and breaks the ability to click on the
  * label and focus on the input
  */
 public function updateMediaForm($form)
 {
     Requirements::javascript(HTMLEDITORIFRAME_BASE . '/javascript/HtmlEditorField_Iframe.js');
     Requirements::css(HTMLEDITORIFRAME_BASE . '/css/HtmlEditorField_Iframe.css');
     $numericLabelTmpl = '<span class="step-label"><span class="flyout">%d</span><span class="arrow"></span>' . '<strong class="title">%s</strong></span>';
     $fromIframe = new CompositeField(new LiteralField('headerIframe', '<h4>' . sprintf($numericLabelTmpl, '1', "Iframe URL") . '</h4>'), $iframeURL = new TextField('IframeURL', 'http://'), new LiteralField('addIframeImage', '<button class="action ui-action-constructive ui-button field add-iframe" data-icon="addMedia">Add url</button>'));
     $iframeURL->addExtraClass('iframeurl');
     $fromIframe->addExtraClass('content ss-uploadfield from-web');
     // $fields->dataFieldByName() doesn't appear to work
     $fields = $form->Fields();
     $tabset = $fields[1]->fieldByName("MediaFormInsertMediaTabs");
     $tabset->push($iFrameTab = new Tab('From an Iframe', $fromIframe));
     $iFrameTab->addExtraClass('htmleditorfield-from-iframe');
     return $form;
 }
 function testFieldHasExtraClass()
 {
     /* TextField has an extra class name and is in the HTML the field returns */
     $textField = new TextField('Name');
     $textField->addExtraClass('thisIsMyClassNameForTheFormField');
     preg_match('/thisIsMyClassNameForTheFormField/', $textField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyClassNameForTheFormField');
     /* EmailField has an extra class name and is in the HTML the field returns */
     $emailField = new EmailField('Email');
     $emailField->addExtraClass('thisIsMyExtraClassForEmailField');
     preg_match('/thisIsMyExtraClassForEmailField/', $emailField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyExtraClassForEmailField');
     /* OptionsetField has an extra class name and is in the HTML the field returns */
     $optionsetField = new OptionsetField('FeelingOk', 'Are you feeling ok?', array(0 => 'No', 1 => 'Yes'), '', null, '(Select one)');
     $optionsetField->addExtraClass('thisIsMyExtraClassForOptionsetField');
     preg_match('/thisIsMyExtraClassForOptionsetField/', $optionsetField->Field(), $matches);
     $this->assertTrue($matches[0] == 'thisIsMyExtraClassForOptionsetField');
 }
예제 #17
0
 function __construct($controller, $name, $use_actions = true)
 {
     $fields = new FieldList();
     //main info
     $fields->push($title = new TextField('title', 'Title'));
     $fields->push($url = new TextField('url', 'Url'));
     $fields->push($description = new HtmlEditorField('description', 'Description'));
     $fields->push($instructions = new HtmlEditorField('instructions', 'Instructions To Apply'));
     $fields->push($expiration_date = new TextField('expiration_date', 'Expiration Date'));
     $fields->push($company = new TextField('company_name', 'Company'));
     $title->addExtraClass('job_control');
     $url->addExtraClass('job_control');
     $description->addExtraClass('job_control');
     $instructions->addExtraClass('job_control');
     $expiration_date->addExtraClass('job_control');
     $company->addExtraClass('job_control');
     //location
     $ddl_locations = new DropdownField('location_type', 'Location Type', array('N/A' => 'N/A', 'Remote' => 'Remote', 'Various' => 'Add a Location'));
     $ddl_locations->addExtraClass('location_type');
     $ddl_locations->addExtraClass('job_control');
     $fields->push($ddl_locations);
     $fields->push($city = new TextField('city', 'City'));
     $fields->push($state = new TextField('state', 'State'));
     $fields->push($country = new CountryDropdownField('country', 'Country'));
     $city->addExtraClass('physical_location');
     $state->addExtraClass('physical_location');
     $country->addExtraClass('physical_location');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveJob', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'company_name', 'instructions', 'description')));
     $this->addExtraClass('job-registration-form');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
 function __construct($controller, $name, $use_actions = true)
 {
     $event_manager = new EventManager($this->repository, new EventRegistrationRequestFactory(), null, new SapphireEventPublishingService(), new EventValidatorFactory(), SapphireTransactionManager::getInstance());
     $fields = new FieldList();
     //point of contact
     $fields->push(new TextField('point_of_contact_name', 'Name'));
     $fields->push(new EmailField('point_of_contact_email', 'Email'));
     //main info
     $fields->push(new TextField('title', 'Title'));
     $fields->push(new TextField('url', 'Url'));
     $types = $event_manager->getAllTypes();
     foreach ($types as $type) {
         $options[$type] = $type;
     }
     $categoryField = new DropdownField('category', 'Category', $options);
     $categoryField->setEmptyString('-- select a category --');
     $fields->push($categoryField);
     //location
     $fields->push(new TextField('city', 'City'));
     $fields->push(new TextField('state', 'State'));
     $countryField = new CountryDropdownField('country', 'Country');
     $countryField->setEmptyString('-- select a country --');
     $fields->push($countryField);
     //duration
     $fields->push($start_date = new TextField('start_date', 'Start Date'));
     $fields->push($end_date = new TextField('end_date', 'End Date'));
     $start_date->addExtraClass('date');
     $end_date->addExtraClass('date');
     // Guard against automated spam registrations by optionally adding a field
     // that is supposed to stay blank (and is hidden from most humans).
     // The label and field name are intentionally common ("username"),
     // as most spam bots won't resist filling it out. The actual username field
     // on the forum is called "Nickname".
     $fields->push(new TextField('user_name', 'UserName'));
     // Create action
     $actions = new FieldList();
     if ($use_actions) {
         $actions->push(new FormAction('saveEventRegistrationRequest', 'Save'));
     }
     // Create validators
     $validator = new ConditionalAndValidationRule(array(new HtmlPurifierRequiredValidator('title', 'city'), new RequiredFields('point_of_contact_name', 'point_of_contact_email', 'start_date', 'end_date', 'country')));
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
예제 #19
0
 function __construct($controller, $name)
 {
     // Name Set
     $FirstNameField = new TextField('FirstName', 'First Name');
     $FirstNameField->addExtraClass('input-text');
     $LastNameField = new TextField('LastName', 'Last Name');
     $LastNameField->addExtraClass('input-text');
     // Email
     $EmailAddressField = new EmailField('EmailAddress', 'Email Address');
     $EmailAddressField->addExtraClass('input-text');
     $fields = new FieldList($FirstNameField, $LastNameField, $EmailAddressField);
     $actions = new FieldList(new FormAction('doSigninForm', 'Sign Up'));
     parent::__construct($controller, $name, $fields, $actions);
     // Create Validators
     $validator = new RequiredFields('FirstName');
     $validator = new RequiredFields('LastName');
     $validator = new RequiredFields('EmailAddress');
     $this->disableSecurityToken();
 }
예제 #20
0
 function RegistrationForm()
 {
     // Name Set
     $FirstNameField = new TextField('FirstName', "First Name");
     $LastNameField = new TextField('Surname', "Last Name");
     // Email Addresses
     $PrimaryEmailField = new TextField('Email', "Primary Email Address");
     // 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');
     $StatementOfInterestField = new TextField('StatementOfInterest', 'Statement of Interest');
     $StatementOfInterestField->addExtraClass('autocompleteoff');
     $affiliations = new FieldGroup(new HeaderField('Affiliations'), new LiteralField("add-affiliation", "<a class='roundedButton' id='add-affiliation' title='Add New Affiliation' href='#'>Add New Affiliation</a>"), new LiteralField("affiliations-container", "<div id='affiliations-container'></div>"));
     $fields = new FieldList($FirstNameField, $LastNameField, new LiteralField('break', '<hr/>'), $PrimaryEmailField, new LiteralField('instructions', '<p>This will also be your login name.</p>'), 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/>'), $affiliations, new HiddenField("Affiliations", "Affiliations", ""), new LiteralField('instructions', '<p>For our purposes, an affiliation is defined as any company where you are an officer, director or employee, or any person or company that has paid you more than $60,000 USD as an independent contractor in the last 12 months. Please list all affiliations which meet this criteria. If you\'re not being paid to work on OpenStack please put "Unaffiliated".</p>'), $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/>'), 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')));
     $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));
     }
     $AdressField = new TextField('Postcode', _t('Addressable.POSTCODE', 'Postcode'));
     $fields->push($AdressField);
     $label = _t('Addressable.COUNTRY', 'Country');
     if (is_array($this->allowedCountries)) {
         $countryField = new DropdownField('Country', $label, $this->allowedCountries);
         $countryField->addExtraClass('chzn-select');
         $countryField->setEmptyString('-- Select One --');
         $fields->push($countryField);
     } elseif (!is_string($this->allowedCountries)) {
         $countryField = new CountryDropdownField('Country', $label);
         $countryField->setEmptyString('-- Select One --');
         $countryField->addExtraClass('chzn-select');
         $fields->push($countryField);
     }
     $fields->push(new LiteralField('break', '<hr/>'));
     $fields->push(new ConfirmedPasswordField('Password', 'Password'));
     $fields->push(new HiddenField('MembershipType', 'MembershipType', 'foundation'));
     $actions = new FieldList(new FormAction('doRegister', 'Submit My Application'));
     $validator = new Member_Validator('FirstName', 'Surname', 'Email', 'StatementOfInterest', 'Address', 'City', 'Country', 'Password');
     return new HoneyPotForm($this, 'RegistrationForm', $fields, $actions, $validator);
 }
    function __construct($controller, $name, $cleanupID)
    {
        if ($cleanupID) {
            $oEvent = DataObject::get_one('CleanUpGroup', "CleanUpGroup.ID = '{$cleanupID}'");
        } else {
            Director::redirectBack();
        }
        $Header = new HeaderField('Send a message', 3);
        $Name = new TextField('FirstName', 'Your name');
        $Phone = new TextField('Phone', 'Your phone number');
        $Email = new TextField('Email', 'Your email');
        $Subject = new TextField('Subject', 'Subject');
        $Message = new TextareaField('Message', 'Your message', '20', '45');
        $Obj = new HiddenField('CleanupID', 'CleanupID', $cleanupID);
        $Name->addExtraClass('Required');
        $Email->addExtraClass('Required');
        $Message->addExtraClass('Required');
        $messageFields = new CompositeField($Header, $Name, $Phone, $Email, $Subject, $Message, $Obj);
        $fields = new FieldSet($messageFields);
        $actions = new FieldSet(new FormAction('processMessage', 'send'));
        //$validator = new RequiredFields('FirstName', 'Email', 'Message');
        Requirements::customScript('
			jQuery(document).ready(function() {

				jQuery("#SendForm_SendForm_FirstName").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#SendForm_SendForm_Name").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#SendForm_SendForm_Email").addClass("validate[required,custom[email]] text-input");
				jQuery("#SendForm_SendForm_Message").addClass("validate[required,length[6,300]] text-input");
				
				jQuery("#SendForm_SendForm").validationEngine()
				
			});
		');
        parent::__construct($controller, $name, $fields, $actions);
        //, $validator);
        $member = Member::currentUser();
        if ($member) {
            $this->loadDataFrom($member);
        }
    }
 public function __construct(ISingleValueTemplateQuestion $question, $value = null)
 {
     $children = new FieldList();
     $this->question = $question;
     $current_user = Member::currentUser();
     $current_affiliations = $current_user->getCurrentAffiliations();
     if (!$current_affiliations) {
         $children->add($txt = new TextField($question->name(), $question->label()));
         $txt->addExtraClass('input-organization-name');
     } else {
         if (intval($current_affiliations->count()) > 1) {
             $source = array();
             foreach ($current_affiliations as $a) {
                 $org = $a->Organization();
                 $source[$org->ID] = $org->Name;
             }
             $source['0'] = "-- New One --";
             $children->add($ddl = new DropdownField($question->name() . 'ID', $question->label(), $source));
             $ddl->setEmptyString('-- Select Your Organization --');
             $ddl->addExtraClass('select-organization-name');
             if (!is_null($value)) {
                 $org = Org::get()->filter('Name', $value)->first();
                 if ($org) {
                     $ddl->setValue($org->ID);
                 }
             }
             $children->add($txt = new TextField($question->name(), ''));
             $txt->addExtraClass('input-organization-name');
         } else {
             $children->add($txt = new TextField($question->name(), $question->label(), $current_user->getOrgName()));
             $txt->addExtraClass('input-organization-name');
         }
     }
     parent::__construct($children);
     $control_css_class = strtolower($this->question->name() . '-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('survey_builder/js/survey.organization.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').survey_organization_field();\n        });");
 }
 /**
  * Initiate the standard Metadata catalogue search form. The 
  * additional parameter $defaults defines the default values for the form.
  * 
  * @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
  * @param String $name The method on the controller that will return this form object.
  * @param FieldSet $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects.
  * @param FieldSet $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects
  * @param Validator $validator Override the default validator instance (Default: {@link RequiredFields})
  */
 function __construct($controller, $name, FieldSet $fields = null, FieldSet $actions = null, $validator = null)
 {
     $recaptchaField = $this->getRecaptchaField();
     if (!$fields) {
         // Create fields
         //adding extra class for custom validation
         $title = new TextField('MDTitle', "TITLE");
         $title->addExtraClass("required");
         $fields = new FieldSet(new CompositeField($title, new TextareaField('MDAbstract'), new CalendarDateField('MDDateTime1'), new DropdownField('MDDateType1', 'DateType', MDCodeTypes::get_date_types(), ""), new CalendarDateField('MDDateTime2'), new DropdownField('MDDateType2', 'DateType', MDCodeTypes::get_date_types(), ""), new CalendarDateField('MDDateTime3'), new DropdownField('MDDateType3', 'DateType', MDCodeTypes::get_date_types(), ""), new ListboxField('MDTopicCategory', 'Category', MDCodeTypes::get_categories(), "", 8, true)), new CompositeField(new DropdownField('MDSpatialRepresentationType', 'Spatial Representation Type', MDCodeTypes::get_spatial_representation_type(), ""), new TextField('MDGeographicDiscription', 'Geographic Description'), new TextField('MDWestBound'), new TextField('MDEastBound'), new TextField('MDSouthBound'), new TextField('MDNorthBound'), new DropdownField('ISOPlaces', 'ISOPlaces', MDCodeTypes::get_places(), "170;180;-52.57806;-32.41472"), new DropdownField('Places', 'Places', NewZealandPlaces::get_nzplaces(), "-141;160;-7;-90"), new DropdownField('OffshoreIslands', 'NZ Offshore islands', NewZealandPlaces::get_nzoffshoreislands(), ""), new DropdownField('Dependencies', 'NZ Dependencies in the South West Pacific', NewZealandPlaces::get_nzdependencies(), ""), new DropdownField('Regions', 'Regions', NewZealandPlaces::get_nzregions(), ""), new DropdownField('TAs', 'TAs', NewZealandPlaces::get_nzta(), "")), new CompositeField(new TextField('MDIndividualName'), new TextField('MDOrganisationName'), new TextField('MDPositionName'), new TextField('MDVoice'), new HiddenField('MDVoiceData'), new EmailField('MDElectronicMailAddress'), new HiddenField('MDElectronicMailAddressData')), new CompositeField(new DropdownField('ResourceFormatsList1', 'ResourceFormatsList1', MDCodeTypes::get_resource_formats(), ""), new TextField('MDResourceFormatName1', 'MDResourceFormatName1', ""), new TextField('MDResourceFormatVersion1', 'MDResourceFormatVersion1', "")), new CompositeField(new DropdownField('ResourceFormatsList2', 'ResourceFormatsList2', MDCodeTypes::get_resource_formats(), ""), new TextField('MDResourceFormatName2', 'MDResourceFormatName2', ""), new TextField('MDResourceFormatVersion2', 'MDResourceFormatVersion2', "")), new CompositeField(new DropdownField('ResourceFormatsList3', 'ResourceFormatsList3', MDCodeTypes::get_resource_formats(), ""), new TextField('MDResourceFormatName3', 'MDResourceFormatName3', ""), new TextField('MDResourceFormatVersion3', 'MDResourceFormatVersion3', "")), new CompositeField(new DropdownField('ResourceFormatsList4', 'ResourceFormatsList4', MDCodeTypes::get_resource_formats(), ""), new TextField('MDResourceFormatName4', 'MDResourceFormatName4', ""), new TextField('MDResourceFormatVersion4', 'MDResourceFormatVersion4', "")), new CompositeField(new DropdownField('ResourceFormatsList5', 'ResourceFormatsList5', MDCodeTypes::get_resource_formats(), ""), new TextField('MDResourceFormatName5', 'MDResourceFormatName5', ""), new TextField('MDResourceFormatVersion5', 'MDResourceFormatVersion5', "")), new CompositeField(new DropDownField('MDHierarchyLevel', 'MDHierarchyLevel', MDCodeTypes::get_scope_codes_keys(), ""), new HiddenField('MDHierarchyLevelData', 'MDHierarchyLevelData', ""), new TextField('MDHierarchyLevelName', 'MDHierarchyLevelName', ""), new HiddenField('MDHierarchyLevelNameData', 'MDHierarchyLevelNameData', ""), new TextField('MDParentIdentifier', 'MDParentIdentifier', "")), new CompositeField(new TextField('CIOnlineLinkage', 'CIOnlineLinkage', ""), new HiddenField('CIOnlineLinkageData', 'CIOnlineLinkageData', ""), new DropdownField('CIOnlineProtocol', 'CIOnlineProtocol', MDCodeTypes::get_online_resource_protocol(), ""), new TextField('CIOnlineName', 'CIOnlineName', ""), new TextField('CIOnlineDescription', 'CIOnlineDescription', ""), new DropdownField('CIOnlineFunction', 'CIOnlineFunction', MDCodeTypes::get_online_resource_function(), "")), new CompositeField(new DropdownField('useLimitation', 'License', MDCodeTypes::get_use_limitation(), "")));
     }
     if ($recaptchaField) {
         $fields->push($recaptchaField);
     }
     if (!$actions) {
         $actions = new FieldSet(new FormAction('doRegisterMetadata', 'Submit'));
     }
     if (!$validator) {
         $validator = new RequiredFields('MDTitle', 'MDAbstract', 'MDElectronicMailAddress', 'MDDateTime', 'MDTopicCategory');
     }
     $validator->setJavascriptValidationHandler('none');
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
    function __construct($controller, $name, $use_actions = true)
    {
        $RatingField = new TextField('rating', '');
        $RatingField->setValue(0);
        $CommentField = new HtmlEditorField('comment', 'Comment');
        $CommentField->setRows(8);
        $sec_field = new TextField('field_98438688', 'field_98438688');
        $sec_field->addExtraClass('honey');
        $fields = new FieldList($RatingField, $CommentField, $sec_field);
        // Create action
        $actions = new FieldList();
        if ($use_actions) {
            $actions->push(new FormAction('submit', 'Submit'));
        }
        $this->addExtraClass('review-form');
        $css = <<<CSS
.honey {
\tposition: absolute; left: -9999px
}
CSS;
        Requirements::customCSS($css, 'honey_css');
        parent::__construct($controller, $name, $fields, $actions);
    }
    function __construct($controller, $name)
    {
        $Header = new HeaderField('Invite people to join your clean up event', 3);
        $Name = new TextField('FirstName', 'Your name');
        $Phone = new TextField('Phone', 'Your phone number');
        $Email = new TextField('Email', 'Your email');
        $Subject = new TextField('Subject', 'Subject');
        $Recipients = new TextField('Recipients', 'Invite members (comma separated)', 'e.g. eg1@eg.co.nz, eg2@eg.co.nz');
        $Message = new TextareaField('Message', 'Your message', '10', '4');
        $Obj = new HiddenField('CleanupID', 'CleanupID');
        $Name->addExtraClass('Required');
        $Email->addExtraClass('Required');
        $Message->addExtraClass('Required');
        $messageFields = new CompositeField($Header, $Name, $Phone, $Email, $Subject, $Recipients, $Message, $Obj);
        $fields = new FieldSet($messageFields);
        $actions = new FieldSet(new FormAction('processInvites', 'send'));
        Requirements::customScript('
			jQuery(document).ready(function() {
		
				jQuery("#InviteForm_InviteForm_FirstName").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#InviteForm_InviteForm_Name").addClass("validate[required,custom[onlyLetter],length[0,100]] text-input");
				jQuery("#InviteForm_InviteForm_Email").addClass("validate[required,custom[email]] text-input");
				jQuery("#InviteForm_InviteForm_Message").addClass("validate[required,length[6,300]] text-input");
				jQuery("#InviteForm_InviteForm_Recipients").addClass("validate[required,length[6,300]] text-input");
				
				jQuery("#InviteForm_InviteForm").validationEngine()
				
				
			});
		');
        parent::__construct($controller, $name, $fields, $actions);
        $member = Member::currentUser();
        if ($member) {
            $this->loadDataFrom($member);
        }
    }
예제 #26
0
 public function __construct($name, $title, $value = null)
 {
     $this->name = $name;
     $this->title = $title;
     $children = new FieldList();
     $source = Company::get()->sort('Name')->map('ID', 'Name')->toArray();
     $source['0'] = "-- New Company --";
     $children->add($ddl = new DropdownField($name . '_id', $title, $source));
     $ddl->setEmptyString('-- Select Your Company --');
     $ddl->addExtraClass('select-company-name');
     if (!is_null($value)) {
         $c = Company::get()->filter('Name', $value)->first();
         if ($c) {
             $ddl->setValue($c->ID);
         }
     }
     $children->add($txt = new TextField($name, ''));
     $txt->addExtraClass('input-company-name');
     parent::__construct($children);
     $control_css_class = strtolower('company-composite');
     $this->addExtraClass($control_css_class);
     Requirements::javascript('openstack/code/utils/CustomHTMLFields/js/company.field.js');
     Requirements::customScript("\n        jQuery(document).ready(function(\$) {\n            \$('.'+'{$control_css_class}').company_field();\n        });");
 }
예제 #27
0
    public function getCMSFields()
    {
        $fields = parent::getCMSFields();
        $fields->removeByName('Order');
        $fields->removeByName('Title');
        $fields->removeByName('ProcessStages');
        $fields->removeByName('StopStages');
        if ($this->ID > 0) {
            $stops = new GridField('StopStages', 'Stopping Points', $this->StopStages(), GridFieldConfig_RelationEditor::create());
            $stopGroup = new ToggleCompositeField('StopStages', 'Stopping points in this process', array(LiteralField::create('StopDescription', '<p class="message info">Create all stops for this process. You can then link to these stops from within any stages you create.</p>'), $stops));
            $stopGroup->setHeadingLevel(5);
        } else {
            $stopGroup = LiteralField::create('NoStopDescription', '<p class="message info">Save this process to add stages and stop stages</p>');
        }
        $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField($title = new TextField('Title', 'Title'), $stopGroup));
        $title->addExtraClass('process-noborder');
        $processSteps->addExtraClass('process-step');
        $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
				<span class="step-label">
					<span class="flyout">1</span><span class="arrow"></span>
					<span class="title">Process details</span>
				</span>
			</h3>'), 'Title');
        if ($this->ID > 0) {
            $fields->addFieldToTab('Root.Main', $processSteps = new CompositeField(new GridField('ProcessStages', 'Process Stages', $this->ProcessStages(), $processStages = GridFieldConfig_RelationEditor::create())));
            $processStages->addComponent(new GridFieldSortableRows('Order'));
            $processSteps->addExtraClass('process-step');
            $fields->insertBefore(new LiteralField('StageTitle', '<h3 class="process-info-header">
					<span class="step-label">
						<span class="flyout">2</span><span class="arrow"></span>
						<span class="title">Stages of this process</span>
					</span>
				</h3>'), 'ProcessStages');
        }
        return $fields;
    }
 /**
  * Return a {@link Form} instance allowing a user to
  * add images and flash objects to the TinyMCE content editor.
  *
  * @return Form
  */
 public function MediaForm()
 {
     // TODO Handle through GridState within field - currently this state set too late to be useful here (during
     // request handling)
     $parentID = $this->getAttachParentID();
     $fileFieldConfig = GridFieldConfig::create()->addComponents(new GridFieldFilterHeader(), new GridFieldSortableHeader(), new GridFieldDataColumns(), new GridFieldPaginator(7), new GridFieldDeleteAction(), new GridFieldDetailForm());
     $fileField = GridField::create('Files', false, null, $fileFieldConfig);
     $fileField->setList($this->getFiles($parentID));
     $fileField->setAttribute('data-selectable', true);
     $fileField->setAttribute('data-multiselect', true);
     $columns = $fileField->getConfig()->getComponentByType('GridFieldDataColumns');
     $columns->setDisplayFields(array('StripThumbnail' => false, 'Title' => _t('File.Title'), 'Created' => singleton('File')->fieldLabel('Created')));
     $columns->setFieldCasting(array('Created' => 'SS_Datetime->Nice'));
     $fromCMS = new CompositeField($select = TreeDropdownField::create('ParentID', "", 'Folder')->addExtraClass('noborder')->setValue($parentID), $fileField);
     $fromCMS->addExtraClass('content ss-uploadfield htmleditorfield-from-cms');
     $select->addExtraClass('content-select');
     $URLDescription = _t('HtmlEditorField.URLDESCRIPTION', 'Insert videos and images from the web into your page simply by entering the URL of the file. Make sure you have the rights or permissions before sharing media directly from the web.<br /><br />Please note that files are not added to the file store of the CMS but embeds the file from its original location, if for some reason the file is no longer available in its original location it will no longer be viewable on this page.');
     $fromWeb = new CompositeField($description = new LiteralField('URLDescription', '<div class="url-description">' . $URLDescription . '</div>'), $remoteURL = new TextField('RemoteURL', 'http://'), new LiteralField('addURLImage', '<button type="button" class="action ui-action-constructive ui-button field font-icon-plus add-url">' . _t('HtmlEditorField.BUTTONADDURL', 'Add url') . '</button>'));
     $remoteURL->addExtraClass('remoteurl');
     $fromWeb->addExtraClass('content ss-uploadfield htmleditorfield-from-web');
     Requirements::css(FRAMEWORK_DIR . '/css/AssetUploadField.css');
     $computerUploadField = Object::create('UploadField', 'AssetUploadField', '');
     $computerUploadField->setConfig('previewMaxWidth', 40);
     $computerUploadField->setConfig('previewMaxHeight', 30);
     $computerUploadField->addExtraClass('ss-assetuploadfield htmleditorfield-from-computer');
     $computerUploadField->removeExtraClass('ss-uploadfield');
     $computerUploadField->setTemplate('HtmlEditorField_UploadField');
     $computerUploadField->setFolderName(Config::inst()->get('Upload', 'uploads_folder'));
     $defaultPanel = new CompositeField($computerUploadField, $fromCMS);
     $fromWebPanel = new CompositeField($fromWeb);
     $defaultPanel->addExtraClass('htmleditorfield-default-panel');
     $fromWebPanel->addExtraClass('htmleditorfield-web-panel');
     $allFields = new CompositeField($defaultPanel, $fromWebPanel, $editComposite = new CompositeField(new LiteralField('contentEdit', '<div class="content-edit ss-uploadfield-files files"></div>')));
     $allFields->addExtraClass('ss-insert-media');
     $headings = new CompositeField(new LiteralField('Heading', sprintf('<h3 class="htmleditorfield-mediaform-heading insert">%s</h3>', _t('HtmlEditorField.INSERTMEDIA', 'Insert media from')) . sprintf('<h3 class="htmleditorfield-mediaform-heading update">%s</h3>', _t('HtmlEditorField.UpdateMEDIA', 'Update media'))));
     $headings->addExtraClass('cms-content-header');
     $editComposite->addExtraClass('ss-assetuploadfield');
     $fields = new FieldList($headings, $allFields);
     $form = new Form($this->controller, "{$this->name}/MediaForm", $fields, new FieldList());
     $form->unsetValidator();
     $form->disableSecurityToken();
     $form->loadDataFrom($this);
     $form->addExtraClass('htmleditorfield-form htmleditorfield-mediaform cms-dialog-content');
     // TODO Re-enable once we remove $.metadata dependency which currently breaks the JS due to $.ui.widget
     // $form->setAttribute('data-urlViewfile', $this->controller->Link($this->name));
     // Allow other people to extend the fields being added to the imageform
     $this->extend('updateMediaForm', $form);
     return $form;
 }
 function ContactForm()
 {
     error_log("Render form");
     $name = _t('ContactPage.NAME', 'Name');
     $email = _t('ContactPage.EMAIL', 'Email');
     $comments = _t('ContactPage.COMMENTS', 'Comments');
     $send = _t('ContactPage.SEND', 'Send');
     // Create fields
     $tf = new TextField('Name', $name);
     $tf->addExtraClass('span11');
     $ef = new EmailField('Email', $email);
     $ef->addExtraClass('span11');
     $taf = new TextareaField('Comments', $comments);
     $taf->addExtraClass('span11');
     $fields = new FieldList($tf, $ef, $taf);
     // Create action
     $fa = new FormAction('SendContactForm', $send);
     // for bootstrap
     $fa->useButtonTag = true;
     $fa->addExtraClass('btn btn-primary');
     $actions = new FieldList($fa);
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Comments');
     $form = new Form($this, 'ContactForm', $fields, $actions, $validator);
     $form->setTemplate('VerticalForm');
     $form->addExtraClass('well');
     return $form;
 }
예제 #30
-1
 public function getHTMLFragments($gridField)
 {
     $fields = new ArrayList();
     $state = $gridField->State->UserFormsGridField;
     $selectedField = $state->filter;
     $selectedValue = $state->value;
     // show dropdown of all the fields available from the submitted form fields
     // that have been saved. Takes the titles from the currently live form.
     $columnField = new DropdownField('FieldNameFilter', '');
     $columnField->setSource($this->columns);
     $columnField->setEmptyString(_t('UserFormsGridFieldFilterHeader.FILTERSUBMISSIONS', 'Filter Submissions..'));
     $columnField->setHasEmptyDefault(true);
     $columnField->setValue($selectedField);
     $valueField = new TextField('FieldValue', '', $selectedValue);
     $columnField->addExtraClass('ss-gridfield-sort');
     $columnField->addExtraClass('no-change-track');
     $valueField->addExtraClass('ss-gridfield-sort');
     $valueField->addExtraClass('no-change-track');
     $valueField->setAttribute('placeholder', _t('UserFormsGridFieldFilterHeader.WHEREVALUEIS', 'where value is..'));
     $fields->push(new FieldGroup(new CompositeField($columnField, $valueField)));
     $fields->push(new FieldGroup(new CompositeField($start = new DateField('StartFilter', 'From'), $end = new DateField('EndFilter', 'Till'))));
     foreach (array($start, $end) as $date) {
         $date->setConfig('showcalendar', true);
         $date->setConfig('dateformat', 'y-mm-dd');
         $date->setConfig('datavalueformat', 'y-mm-dd');
         $date->addExtraClass('no-change-track');
     }
     $end->setValue($state->end);
     $start->setValue($state->start);
     $fields->push($actions = new FieldGroup(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), 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)));
     $actions->addExtraClass('filter-buttons');
     $actions->addExtraClass('no-change-track');
     $forTemplate = new ArrayData(array('Fields' => $fields));
     return array('header' => $forTemplate->renderWith('GridFieldFilterHeader_Row'));
 }