public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
    {
        if (!$fields) {
            $helpHtml = _t('GroupImportForm.Help1', '<p>Import one or more groups in <em>CSV</em> format (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
            $helpHtml .= _t('GroupImportForm.Help2', '<div class="advanced">
	<h4>Advanced usage</h4>
	<ul>
	<li>Allowed columns: <em>%s</em></li>
	<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the 
	imported file</li>
	<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>
	<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not
	cleared.</li>
	</ul>
</div>');
            $importer = new GroupCsvBulkLoader();
            $importSpec = $importer->getImportSpec();
            $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
            $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
            $fileField->getValidator()->setAllowedExtensions(array('csv'));
        }
        if (!$actions) {
            $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
            $action->addExtraClass('ss-ui-button');
            $actions = new FieldList($action);
        }
        if (!$validator) {
            $validator = new RequiredFields('CsvFile');
        }
        parent::__construct($controller, $name, $fields, $actions, $validator);
        $this->addExtraClass('cms');
        $this->addExtraClass('import-form');
    }
 /**
  * @return Form|SS_HTTPResponse
  */
 public function EditProfileForm()
 {
     if (!Member::currentUser()) {
         $this->setFlash(_t('EditProfilePage.LoginWarning', 'Please login to edit your profile'), 'warning');
         return $this->redirect(Director::absoluteBaseURL());
     }
     $firstName = new TextField('FirstName');
     $firstName->setAttribute('placeholder', _t('EditProfilePage.FirstNamePlaceholder', 'Enter your first name'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $surname = new TextField('Surname');
     $surname->setAttribute('placeholder', _t('EditProfilePage.SurnamePlaceholder', 'Enter your surname'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $email = new EmailField('Email');
     $email->setAttribute('placeholder', _t('EditProfilePage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $jobTitle = new TextField('JobTitle');
     $jobTitle->setAttribute('placeholder', _t('EditProfilePage.JobTitlePlaceholder', 'Enter your job title'))->addExtraClass('form-control');
     $website = new TextField('Website');
     $website->setAttribute('placeholder', _t('EditProfilePage.WebsitePlaceholder', 'Enter your website'))->addExtraClass('form-control');
     $blurb = new TextareaField('Blurb');
     $blurb->setAttribute('placeholder', _t('EditProfilePage.BlurbPlaceholder', 'Enter your blurb'))->addExtraClass('form-control');
     $confirmPassword = new ConfirmedPasswordField('Password', _t('EditProfilePage.PasswordLabel', 'New Password'));
     $confirmPassword->canBeEmpty = true;
     $confirmPassword->setAttribute('placeholder', _t('EditProfilePage.PasswordPlaceholder', 'Enter your password'))->addExtraClass('form-control');
     $fields = new FieldList($firstName, $surname, $email, $jobTitle, $website, $blurb, $confirmPassword);
     $action = new FormAction('SaveProfile', _t('EditProfilePage.SaveProfileText', 'Update Profile'));
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     // Create action
     $validator = new RequiredFields('FirstName', 'Email');
     //Create form
     $form = new Form($this, 'EditProfileForm', $fields, $actions, $validator);
     //Populate the form with the current members data
     $Member = Member::currentUser();
     $form->loadDataFrom($Member->data());
     //Return the form
     return $form;
 }
 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);
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('MemberImportForm.Help1', '<p>Import users in <em>CSV format</em> (comma-separated values).' . ' <small><a href="#" class="toggle-advanced">Show advanced usage</a></small></p>');
         $helpHtml .= _t('MemberImportForm.Help2', '<div class="advanced">' . '<h4>Advanced usage</h4>' . '<ul>' . '<li>Allowed columns: <em>%s</em></li>' . '<li>Existing users are matched by their unique <em>Code</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>' . '</div>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('CsvFile', _t('SecurityAdmin_MemberImportForm.FileFieldLabel', 'CSV File <small>(Allowed extensions: *.csv)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('SecurityAdmin_MemberImportForm.BtnImport', 'Import from CSV'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-entwine/dist/jquery.entwine-dist.js');
     Requirements::javascript(FRAMEWORK_ADMIN_DIR . '/javascript/MemberImportForm.js');
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 function __construct($controller, $name)
 {
     $SearchField = new TextField('Search', 'Search');
     $fields = new FieldList($SearchField);
     $searchButton = new FormAction('doSearch', 'Search');
     $searchButton->addExtraClass('button');
     $actions = new FieldList($searchButton);
     parent::__construct($controller, $name, $fields, $actions);
 }
 function __construct($controller, $name)
 {
     $FeedbackField = new TextareaField('Content', 'My Feedback About This Page');
     $fields = new FieldList($FeedbackField);
     $tellUsButton = new FormAction('submitFeedback', 'Tell Us');
     $tellUsButton->addExtraClass('button');
     $actions = new FieldList($tellUsButton);
     parent::__construct($controller, $name, $fields, $actions);
 }
Beispiel #7
0
 function __construct($controller, $name, $fields, $validator, $readonly, $dataObject)
 {
     $this->dataObject = $dataObject;
     Requirements::clear();
     $actions = new FieldList();
     if (!$readonly) {
         $actions->push($saveAction = new FormAction("saveComplexTableField", "Save"));
         $saveAction->addExtraClass('save');
     }
     $fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
     parent::__construct($controller, $name, $fields, $validator, $readonly, $dataObject);
 }
	function __construct($controller, $name, $fields, $validator, $readonly, $dataObject) {
		$this->dataObject = $dataObject;

		/**
		 * WARNING: DO NOT CHANGE THE ORDER OF THESE JS FILES
		 * Some have special requirements.
		 */
		//Requirements::css(CMS_DIR . 'css/layout.css');
		Requirements::css(SAPPHIRE_DIR . '/css/Form.css');
		Requirements::css(SAPPHIRE_DIR . '/css/ComplexTableField_popup.css');
		Requirements::css(CMS_DIR . '/css/typography.css');
		Requirements::css(CMS_DIR . '/css/cms_right.css');
		Requirements::css(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.css');
		Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
		Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
		Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/scriptaculous.js");
		Requirements::javascript(THIRDPARTY_DIR . "/scriptaculous/controls.js");
		Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
		Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain_right.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/TableField.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField.js");
		Requirements::javascript(SAPPHIRE_DIR . "/javascript/ComplexTableField_popup.js");
		// jQuery requirements (how many of these are actually needed?)
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery_improvements.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.core.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/ui/ui.tabs.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/form/jquery.form.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/dimensions/jquery.dimensions.js');
		Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/autocomplete/jquery.ui.autocomplete.js');
		Requirements::javascript(SAPPHIRE_DIR . '/javascript/ScaffoldComplexTableField.js');
		Requirements::javascript(CMS_DIR . '/javascript/ModelAdmin.js');
		
 		if($this->dataObject->hasMethod('getRequirementsForPopup')) {
			$this->dataObject->getRequirementsForPopup();
		}
		
		$actions = new FieldSet();	
		if(!$readonly) {
			$actions->push(
				$saveAction = new FormAction("saveComplexTableField", "Save")
			);	
			$saveAction->addExtraClass('save');
		}
		
		$fields->push(new HiddenField("ComplexTableField_Path", Director::absoluteBaseURL()));
		
		parent::__construct($controller, $name, $fields, $actions, $validator);
	}
 function ContactForm()
 {
     // Create fields
     $fields = new FieldList(TextField::create('Name')->setTitle(_t('ContactPage.NAMEINPUT', "Name <em>*</em>")), TextField::create("Cellphone")->setTitle(_t('ContactPage.CELLPHONE', "Cellphone")), EmailField::create("Email")->setTitle(_t('ContactPage.EMAIL', "Email address"))->setAttribute('type', 'email'), TextareaField::create("Question")->setTitle(_t('ContactPage.QUESTION', "Question <em>*</em>")));
     $this->extend('updateContactForm', $fields);
     // Create action
     $send = new FormAction('SendContactForm', _t('ContactPage.SEND', "Send"));
     $send->addExtraClass("success btn");
     $actions = new FieldList($send);
     // Create action
     $validator = new RequiredFields('Name', 'Email', 'Question');
     return new Form($this, 'ContactForm', $fields, $actions, $validator);
 }
Beispiel #10
0
 public function getCMSActions()
 {
     $actions = parent::getCMSActions();
     $addCreditCard = new FormAction('addCreditCard', 'Add Credit Card');
     $addCreditCard->addExtraClass('ss-ui-action-constructive');
     $updateCreditCard = new FormAction('updateCreditCard', 'Update Credit Card');
     $updateCreditCard->addExtraClass('ss-ui-action-constructive');
     if ($this->ID) {
         $actions->push($updateCreditCard);
     }
     if (!$this->ID) {
         $actions->push($addCreditCard);
     }
     return $actions;
 }
Beispiel #11
0
 public function getCMSActions()
 {
     $actions = parent::getCMSActions();
     $createSubscription = new FormAction('createSubscription', 'Create Subscription');
     $createSubscription->addExtraClass('ss-ui-action-constructive');
     $cancelSubscription = new FormAction('cancelSubscription', 'Cancel Subscription');
     $cancelSubscription->addExtraClass('ss-ui-action-destructive');
     $changeSubscription = new FormAction('changeSubscription', 'Change Subscription');
     $changeSubscription->addExtraClass('ss-ui-action-constructive');
     if ($this->ID && $this->Status && ($this->ProductID == 1 || $this->ProductID == 2 || $this->ProductID == 3)) {
         $actions->push($cancelSubscription);
         $actions->push($changeSubscription);
     }
     if (!$this->ID) {
         $actions->push($createSubscription);
     }
     return $actions;
 }
 public function OrderForm($id = null)
 {
     $product = empty($id) ? new Product() : DataObject::get_one('Product', array('ID' => (int) $id));
     try {
         $processor = PaymentFactory::factory($this->paymentMethod);
     } catch (Exception $e) {
         $fields = new FieldList(array(new ReadonlyField($e->getMessage())));
         $actions = new FieldList();
         return new Form($this, 'OrderForm', $fields, $actions);
     }
     $fields = new FieldList();
     $fields->push(new HiddenField('Amount', 'Amount', $product->Price));
     $fields->push(new HiddenField('Currency', 'Currency', 'NZD'));
     $fields->push(new HiddenField('PaymentMethod', 'PaymentMethod', 'PayPalExpress'));
     $actions = new FieldList($button = new FormAction('processOrder', 'Buy Now'));
     $button->addExtraClass('button expand');
     $validator = $processor->getFormRequirements();
     $form = new Form($this, "OrderForm", $fields, $actions, $validator);
     $form->setTemplate('OrderForm');
     return $form;
 }
 /**
  * @return static
  */
 function RegistrationForm()
 {
     // Email
     $email = new EmailField('Email');
     $email->setAttribute('placeholder', _t('RegistrationPage.EmailPlaceholder', 'Enter your email address'))->setAttribute('required', 'required')->addExtraClass('form-control');
     // Password Conformation
     $password = new PasswordField('Password');
     $password->setAttribute('placeholder', _t('RegistrationPage.PasswordPlaceholder', 'Enter your password'))->setCustomValidationMessage(_t('RegistrationPage.PasswordValidationText', 'Your passwords do not match'), 'validation')->setAttribute('required', 'required')->addExtraClass('form-control');
     // Generate the fields
     $fields = new FieldList($email, $password);
     // Submit Button
     $action = new FormAction('Register', 'Register');
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     $validator = new RequiredFields('Email', 'Password');
     $form = Form::create($this, 'RegistrationForm', $fields, $actions, $validator);
     if ($formData = Session::get('FormInfo.Form_RegistrationForm.data')) {
         $form->loadDataFrom($formData);
     }
     return $form;
 }
 function __construct($controller, $name)
 {
     $f = new FieldList();
     $f->push(BootstrapTextField::create('Name', "Full name"));
     $f->push(BootstrapEmailField::create('Email', "Email (will not be published)"));
     $f->push(BootstrapEmailField::create('ContactNumber', 'Contact number (will not be published)'));
     $f->push(CustomCountryDropdownField::create('Country')->setEmptyString('--please select--'));
     $f->push(BootstrapTextField::create('Town'));
     $f->push(BootstrapTextField::create('Latitude'));
     $f->push(BootstrapTextField::create('Longitude'));
     $f->push(FileField::create('Image'));
     $f->push(BootstrapTextareaField::create('Description')->setRightTitle("<div id='charLeft'><span>200</span></div>"));
     $actions = new FieldList($btn = new FormAction('doSubmit', 'Submit'));
     $btn->addExtraClass("btn");
     $aRequiredFields = array();
     $aRequiredFields[] = "Name";
     $aRequiredFields[] = "Email";
     $aRequiredFields[] = "Description";
     $requiredFields = new RequiredFields();
     parent::__construct($controller, $name, $f, $actions, $requiredFields);
     $this->addExtraClass('form-horizontal ' . get_class());
     //$this->loadValidationScripts($this, $aRequiredFields);
 }
 /**
  * @param ISurveyStep $step
  * @param string $action
  * @param string $form_name
  * @return Form
  */
 public function build(ISurveyStep $step, $action, $form_name = 'SurveyStepForm')
 {
     $form = parent::build($step, $action, $form_name);
     $entity_survey = $step->survey();
     if ($entity_survey instanceof IEntitySurvey) {
         $fields = $form->Fields();
         $first = $fields->first();
         if ($entity_survey->isTeamEditionAllowed() && $entity_survey->createdBy()->getIdentifier() === Member::currentUserID() && $entity_survey->isFirstStep()) {
             $fields->insertBefore($team_field = new EntitySurveyEditorTeamField('EditorTeam', '', $entity_survey), $first->getName());
             $team_field->setForm($form);
             $first = $team_field;
         }
         $edition_info_panel = '<div class="container editor-info-panel"><div class="row">Created by <b>' . $entity_survey->createdBy()->getEmail() . '</b></div>';
         $edition_info_panel .= '<div class="row">Edited by <b>' . $entity_survey->EditedBy()->getEmail() . '</b></div></div>';
         $fields->insertBefore(new LiteralField('owner_label', $edition_info_panel), $first->getName());
         $previous_step = $entity_survey->getPreviousStep($step->template()->title());
         if (!is_null($previous_step)) {
             $request = Controller::curr()->getRequest();
             $step = $request->param('STEP_SLUG');
             if (empty($step)) {
                 $step = $request->requestVar('STEP_SLUG');
             }
             if (empty($step)) {
                 throw new LogicException('step empty! - member_id %s', Member::currentUserID());
             }
             $entity_survey_id = intval($request->param('ENTITY_SURVEY_ID'));
             $prev_step_url = Controller::join_links(Director::absoluteBaseURL(), Controller::curr()->Link(), $step, 'edit', $entity_survey_id, $previous_step->template()->title());
             // add prev button
             $actions = $form->Actions();
             $btn = $actions->offsetGet(0);
             $actions->insertBefore($prev_action = new FormAction('PrevStep', 'Prev Step'), $btn->name);
             $prev_action->addExtraClass('entity-survey-prev-action');
             $prev_action->setAttribute('data-prev-url', $prev_step_url);
         }
     }
     return $form;
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('ExcelMemberImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Member')));
         $helpHtml .= _t('ExcelMemberImportForm.Help2', '<ul>' . '<li>Existing users are matched by their unique <em>Email</em> property, and updated with any new values from ' . 'the imported file.</li>' . '<li>Groups can be assigned by the <em>Groups</em> column. Groups are identified by their <em>Code</em> property, ' . 'multiple groups can be separated by comma. Existing group memberships are not cleared.</li>' . '</ul>');
         $importer = new MemberCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelMemberImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
         $fileField->getValidator()->setAllowedExtensions(ExcelImportExport::getValidExtensions());
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('ExcelMemberImportForm.BtnImport', 'Import from file'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('File');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 public function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('ExcelGroupImportForm.Help1', '<p><a href="{link}">Download sample file</a></p>', array('link' => $controller->Link('downloadsample/Group')));
         $helpHtml .= _t('ExcelGroupImportForm.Help2', '<ul>' . '<li>Existing groups are matched by their unique <em>Code</em> value, and updated with any new values from the ' . 'imported file</li>' . '<li>Group hierarchies can be created by using a <em>ParentCode</em> column.</li>' . '<li>Permission codes can be assigned by the <em>PermissionCode</em> column. Existing permission codes are not ' . 'cleared.</li>' . '</ul>');
         $importer = new GroupCsvBulkLoader();
         $importSpec = $importer->getImportSpec();
         $helpHtml = sprintf($helpHtml, implode(', ', array_keys($importSpec['fields'])));
         $extensions = array('csv', 'xls', 'xlsx', 'ods', 'txt');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('File', _t('ExcelGroupImportForm.FileFieldLabel', 'File <small><br/>(allowed extensions: {extensions})</small>', array('extensions' => implode(', ', $extensions)))));
         $fileField->getValidator()->setAllowedExtensions(array('csv'));
     }
     if (!$actions) {
         $action = new FormAction('doImport', _t('ExcelGroupImportForm.BtnImport', 'Import from file'));
         $action->addExtraClass('ss-ui-button');
         $actions = new FieldList($action);
     }
     if (!$validator) {
         $validator = new RequiredFields('File');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
Beispiel #18
0
 /**
  * Build the file selection form.
  *
  * @return Form
  */
 public function Form()
 {
     // Find out the requested folder ID.
     $folderID = $this->parent->getRequest()->requestVar('ParentID');
     if (!isset($folderID)) {
         $folder = Folder::find_or_make($this->folderName);
         $folderID = $folder ? $folder->ID : 0;
     }
     // Construct the form
     $action = new FormAction('doAttach', _t('UploadField.AttachFile', 'Attach file(s)'));
     $action->addExtraClass('ss-ui-action-constructive icon-accept');
     $form = new Form($this, 'Form', new FieldList($this->getListField($folderID)), new FieldList($action));
     // Add a class so we can reach the form from the frontend.
     $form->addExtraClass('uploadfield-form');
     return $form;
 }
 /**
  *
  * @param Controller
  * @param String
  */
 function __construct(Controller $controller, $name)
 {
     //set basics
     $requiredFields = array();
     //requirements
     Requirements::javascript('ecommerce/javascript/EcomOrderFormAddress.js');
     // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         Requirements::javascript('ecommerce/javascript/EcomOrderFormShipping.js');
         // LEAVE HERE - NOT EASY TO INCLUDE VIA TEMPLATE
     }
     //  ________________ 1) Order + Member + Address fields
     //find member
     $this->order = ShoppingCart::current_order();
     $this->orderMember = $this->order->CreateOrReturnExistingMember(false);
     $this->loggedInMember = Member::currentUser();
     //strange security situation...
     if ($this->orderMember->exists() && $this->loggedInMember) {
         if ($this->orderMember->ID != $this->loggedInMember->ID) {
             if (!$this->loggedInMember->IsShopAdmin()) {
                 $this->loggedInMember->logOut();
             }
         }
     }
     $addressFieldsBilling = new FieldList();
     //member fields
     if ($this->orderMember) {
         $memberFields = $this->orderMember->getEcommerceFields();
         $requiredFields = array_merge($requiredFields, $this->orderMember->getEcommerceRequiredFields());
         $addressFieldsBilling->merge($memberFields);
     }
     //billing address field
     $billingAddress = $this->order->CreateOrReturnExistingAddress("BillingAddress");
     $billingAddressFields = $billingAddress->getFields($this->orderMember);
     $requiredFields = array_merge($requiredFields, $billingAddress->getRequiredFields());
     $addressFieldsBilling->merge($billingAddressFields);
     //shipping address field
     $addressFieldsShipping = null;
     if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
         $addressFieldsShipping = new FieldList();
         //add the important CHECKBOX
         $useShippingAddressField = new FieldList(new CheckboxField("UseShippingAddress", _t("OrderForm.USESHIPPINGADDRESS", "Use an alternative shipping address")));
         $addressFieldsShipping->merge($useShippingAddressField);
         //now we can add the shipping fields
         $shippingAddress = $this->order->CreateOrReturnExistingAddress("ShippingAddress");
         $shippingAddressFields = $shippingAddress->getFields($this->orderMember);
         //we have left this out for now as it was giving a lot of grief...
         //$requiredFields = array_merge($requiredFields, $shippingAddress->getRequiredFields());
         //finalise left fields
         $addressFieldsShipping->merge($shippingAddressFields);
     }
     $leftFields = new CompositeField($addressFieldsBilling);
     $leftFields->addExtraClass('leftOrderBilling');
     $allLeftFields = new CompositeField($leftFields);
     $allLeftFields->addExtraClass('leftOrder');
     if ($addressFieldsShipping) {
         $leftFieldsShipping = new CompositeField($addressFieldsShipping);
         $leftFieldsShipping->addExtraClass('leftOrderShipping');
         $allLeftFields->push($leftFieldsShipping);
     }
     //  ________________  2) Log in / vs Create Account fields - RIGHT-HAND-SIDE fields
     $rightFields = new CompositeField();
     $rightFields->addExtraClass('rightOrder');
     //to do: simplify
     if (EcommerceConfig::get("EcommerceRole", "allow_customers_to_setup_accounts")) {
         if ($this->orderDoesNotHaveFullyOperationalMember()) {
             //general header
             if (!$this->loggedInMember) {
                 $rightFields->push(new LiteralField('MemberInfo', '<p class="message good">' . _t('OrderForm.MEMBERINFO', 'If you already have an account then please') . " <a href=\"Security/login/?BackURL=/" . urlencode(implode("/", $controller->getURLParams())) . "\">" . _t('OrderForm.LOGIN', 'log in') . '</a>.</p>'));
             }
         } else {
             if ($this->loggedInMember) {
                 $rightFields->push(new LiteralField('LoginNote', "<p class=\"message good\">" . _t("Account.LOGGEDIN", "You are logged in as ") . Convert::raw2xml($this->loggedInMember->FirstName) . ' ' . Convert::raw2xml($this->loggedInMember->Surname) . ' (' . Convert::raw2xml($this->loggedInMember->Email) . ').' . ' <a href="/Security/logout/">' . _t("Account.LOGOUTNOW", "Log out?") . '</a>' . '</p>'));
             }
         }
         if ($this->orderMember->exists()) {
             if ($this->loggedInMember) {
                 if ($this->loggedInMember->ID != $this->orderMember->ID) {
                     $rightFields->push(new LiteralField('OrderAddedTo', "<p class=\"message good\">" . _t("Account.ORDERADDEDTO", "Order will be added to ") . Convert::raw2xml($this->orderMember->FirstName) . ' ' . Convert::raw2xml($this->orderMember->Surname) . ' (' . Convert::raw2xml($this->orderMember->Email) . ').</p>'));
                 }
             }
         }
     }
     //  ________________  5) Put all the fields in one FieldList
     $fields = new FieldList($rightFields, $allLeftFields);
     //  ________________  6) Actions and required fields creation + Final Form construction
     $nextButton = new FormAction('saveAddress', _t('OrderForm.NEXT', 'Next'));
     $nextButton->addExtraClass("next");
     $actions = new FieldList($nextButton);
     $validator = OrderFormAddress_Validator::create($requiredFields);
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->setAttribute("autocomplete", "off");
     //extensions need to be set after __construct
     //extension point
     $this->extend('updateFields', $fields);
     $this->setFields($fields);
     $this->extend('updateActions', $actions);
     $this->setActions($actions);
     $this->extend('updateValidator', $validator);
     $this->setValidator($validator);
     //this needs to come after the extension calls
     foreach ($validator->getRequired() as $requiredField) {
         $field = $fields->dataFieldByName($requiredField);
         if ($field) {
             $field->addExtraClass("required");
         }
     }
     //  ________________  7)  Load saved data
     //we do this first so that Billing and Shipping Address can override this...
     if ($this->orderMember) {
         $this->loadDataFrom($this->orderMember);
     }
     if ($this->order) {
         $this->loadDataFrom($this->order);
         if ($billingAddress) {
             $this->loadDataFrom($billingAddress);
         }
         if (EcommerceConfig::get("OrderAddress", "use_separate_shipping_address")) {
             if ($shippingAddress) {
                 $this->loadDataFrom($shippingAddress);
             }
         }
     }
     //allow updating via decoration
     $oldData = Session::get("FormInfo.{$this->FormName()}.data");
     if ($oldData && (is_array($oldData) || is_object($oldData))) {
         $this->loadDataFrom($oldData);
     }
     $this->extend('updateOrderFormAddress', $this);
 }
 function __construct($controller, $name, $fields, $validator, $readonly, $dataObject)
 {
     $this->dataObject = $dataObject;
     Requirements::clear();
     Requirements::unblock_all();
     $actions = new FieldSet();
     if (!$readonly) {
         $actions->push($saveAction = new FormAction("saveComplexTableField", _t('CMSMain.SAVE')));
         $saveAction->addExtraClass('save');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
 }
Beispiel #21
0
 /**
  * Creates the edit form for a file given a File object.
  *
  * @todo This is a bit ugly -- the first parameter is a SS_HTTPRequest on POST, but
  *		 otherwise a File.
  * @param SS_HTTPRequest|File Ambiguous first paramteter!
  * @return Form
  */
 public function FileEditForm($file = null)
 {
     $fields = new FieldSet();
     if ($file instanceof File) {
         $fields = $this->getFieldsForFile($file);
     } elseif ($this->getRequest()->requestVar('ID')) {
         if ($file = DataObject::get_by_id("File", (int) $this->getRequest()->requestVar('ID'))) {
             $fields = $this->getFieldsForFile($file);
         }
     }
     $f = new Form($this, "FileEditForm", $fields, new FieldSet($save = new FormAction('doFileSave', _t('KickAssetts.SAVE', 'Save')), $cancel = new FormAction('doFileCancel', _t('KickAssetts.CANCEL', 'Cancel'))));
     $save->useButtonTag = true;
     $cancel->useButtonTag = true;
     $save->addExtraClass("btn primary");
     $cancel->addExtraClass("btn");
     return $f;
 }
 /**
  * Returns the folder selection dropdown to the template
  *
  * @param int $id The ID of the folder that is selected
  * @return DropdownField
  */
 public function FolderDropdown($id = null)
 {
     if (!$id) {
         $id = $this->CurrentUploadFolder()->ID;
     }
     $group = new FieldGroup($d = new SimpleTreeDropdownField("UploadFolderID_{$this->id()}", '', "Folder", $id, "Filename"), new LiteralField("slash{$this->id()}", " / "), new TextField("NewFolder_{$this->id()}", ""), $a = new FormAction("ok_{$this->id()}", _t('Uploadify.CHANGEFOLDERACTION', 'Change')));
     $a->useButtonTag = true;
     $a->addExtraClass("{'url' : '" . $this->Link('newfolder') . "' }");
     $d->setValue($id);
     return $group;
 }
 function Form()
 {
     if (isset($_REQUEST["BackURL"])) {
         Session::set('BackURL', $_REQUEST["BackURL"]);
     }
     $member = Member::currentUser();
     $fields = new FieldList();
     $passwordField = null;
     if ($member) {
         $name = $member->getName();
         //if($member && $member->Password != '') {$passwordField->setCanBeEmpty(true);}
         $action = new FormAction("submit", "Update your details");
         $action->addExtraClass("updateButton");
         $actions = new FieldList($action);
     } else {
         $passwordField = new ConfirmedPasswordField("Password", "Password");
         $action = new FormAction("submit", "Register");
         $action->addExtraClass("registerButton");
         $actions = new FieldList($action);
         $member = new Member();
     }
     $memberFormFields = $member->getMemberFormFields();
     if ($memberFormFields) {
         if (is_array(self::$fields_to_remove) && count(self::$fields_to_remove)) {
             foreach (self::$fields_to_remove as $fieldName) {
                 $memberFormFields->removeByName($fieldName);
             }
         }
         $fields->merge($memberFormFields);
     }
     if ($passwordField) {
         $fields->push($passwordField);
     }
     foreach (self::$required_fields as $fieldName) {
         $fields->fieldByName($fieldName)->addExtraClass("RequiredField");
     }
     $requiredFields = new RequiredFields(self::$required_fields);
     $form = new Form($this, "Form", $fields, $actions, $requiredFields);
     // Load any data avaliable into the form.
     if ($member) {
         $member->Password = null;
         $form->loadDataFrom($member);
     }
     $data = Session::get("FormInfo.Form_Form.data");
     if (is_array($data)) {
         $form->loadDataFrom($data);
     }
     // Optional spam protection
     if (class_exists('SpamProtectorManager')) {
         SpamProtectorManager::update_form($form);
     }
     if (!isset($_REQUEST["Password"])) {
         $form->fields()->fieldByName("Password")->SetValue("");
     }
     return $form;
 }
Beispiel #24
0
 /**
  * Get the actions available in the CMS for this page - eg Save, Publish.
  * @return FieldSet The available actions for this page.
  */
 function getCMSActions()
 {
     $actions = new FieldSet();
     // "readonly"/viewing version that isn't the current version of the record
     $stageOrLiveRecord = Versioned::get_one_by_stage($this->class, Versioned::current_stage(), sprintf('"SiteTree"."ID" = %d', $this->ID));
     if ($stageOrLiveRecord && $stageOrLiveRecord->Version != $this->Version) {
         $actions->push(new FormAction('email', _t('CMSMain.EMAIL', 'Email')));
         $actions->push(new FormAction('rollback', _t('CMSMain.ROLLBACK', 'Roll back to this version')));
         // getCMSActions() can be extended with updateCMSActions() on a decorator
         $this->extend('updateCMSActions', $actions);
         return $actions;
     }
     if ($this->isPublished() && $this->canPublish() && !$this->IsDeletedFromStage) {
         // "unpublish"
         $unpublish = FormAction::create('unpublish', _t('SiteTree.BUTTONUNPUBLISH', 'Unpublish'), 'delete');
         $unpublish->describe(_t('SiteTree.BUTTONUNPUBLISHDESC', 'Remove this page from the published site'));
         $unpublish->addExtraClass('delete');
         $actions->push($unpublish);
     }
     if ($this->stagesDiffer('Stage', 'Live') && !$this->IsDeletedFromStage) {
         if ($this->isPublished() && $this->canEdit()) {
             // "rollback"
             $rollback = FormAction::create('rollback', _t('SiteTree.BUTTONCANCELDRAFT', 'Cancel draft changes'), 'delete');
             $rollback->describe(_t('SiteTree.BUTTONCANCELDRAFTDESC', 'Delete your draft and revert to the currently published page'));
             $rollback->addExtraClass('delete');
             $actions->push($rollback);
         }
     }
     if ($this->canEdit()) {
         if ($this->IsDeletedFromStage) {
             if ($this->ExistsOnLive) {
                 // "restore"
                 $actions->push(new FormAction('revert', _t('CMSMain.RESTORE', 'Restore')));
                 if ($this->canDelete() && $this->canDeleteFromLive()) {
                     // "delete from live"
                     $actions->push(new FormAction('deletefromlive', _t('CMSMain.DELETEFP', 'Delete from the published site')));
                 }
             } else {
                 // "restore"
                 $actions->push(new FormAction('restore', _t('CMSMain.RESTORE', 'Restore')));
             }
         } else {
             if ($this->canDelete()) {
                 // "delete"
                 $actions->push($deleteAction = new FormAction('delete', _t('CMSMain.DELETE', 'Delete from the draft site')));
                 $deleteAction->addExtraClass('delete');
             }
             // "save"
             $actions->push(new FormAction('save', _t('CMSMain.SAVE', 'Save')));
         }
     }
     if ($this->canPublish() && !$this->IsDeletedFromStage) {
         // "publish"
         $actions->push(new FormAction('publish', _t('SiteTree.BUTTONSAVEPUBLISH', 'Save and Publish')));
     }
     // getCMSActions() can be extended with updateCMSActions() on a decorator
     $this->extend('updateCMSActions', $actions);
     return $actions;
 }
 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;
 }
 function __construct($controller, $name, $fields = null, $actions = null, $validator = null)
 {
     if (!$fields) {
         $helpHtml = _t('TemplateImportForm.Help1');
         $fields = new FieldList(new LiteralField('Help', $helpHtml), $fileField = new FileField('TemplateFile', _t('DynamicTemplateAdmin_TemplateImportForm.FileFieldLabel', 'Template File <small>(Allowed extensions: *.tar.gz, .zip)</small>')));
         $fileField->getValidator()->setAllowedExtensions(array('gz', 'zip'));
     }
     if (!$actions) {
         $actions = new FieldList($importAction = new FormAction('doImport', _t('DynamicTemplateAdmin_TemplateImportForm.BtnImport', 'Import')));
     }
     $importAction->addExtraClass('ss-ui-button');
     if (!$validator) {
         $validator = new RequiredFields('CsvFile');
     }
     parent::__construct($controller, $name, $fields, $actions, $validator);
     $this->addExtraClass('cms');
     $this->addExtraClass('import-form');
 }
 public function SearchForm()
 {
     $searchText = $this->GetSearchTerm() ?: "";
     $queryType = $this->GetSearchType() ?: "";
     $category = $this->GetCategory() ?: "";
     $searchField = new TextField('Search', "Search youtube for:", $searchText);
     $searchField->setAttribute('placeholder', "Type here");
     $fields = new FieldList(new DropdownField('queryType', "Search type:", array('relevance' => 'All Videos', 'viewcount' => 'Most Viewed Videos', 'date' => 'Most recent', 'rating' => 'Top rated'), $queryType), new DropdownField('category', "Category:", $this->GetCategories(), $category), $searchField);
     $action = new FormAction('YouTubeSearchResults', _t('SearchForm.GO', 'Go'));
     $action->addExtraClass('btn btn-default btn-search');
     $action->useButtonTag = true;
     $action->setButtonContent('<i class="fa fa-search"></i><span class="text-hide">Search</span>');
     $actions = new FieldList($action);
     $form = new Form($this, 'YouTubeSearchForm', $fields, $actions);
     $form->setFormMethod('GET');
     $form->setFormAction($this->Link() . "");
     $form->disableSecurityToken();
     return $form;
 }
 /**
  * @return static
  */
 public function ContactForm()
 {
     /* -----------------------------------------
         * Scaffolding
        ------------------------------------------*/
     $row = new LiteralField('', '<div class="row">');
     $column = new LiteralField('', '<div class="col-xs-12 col-sm-6">');
     $close = new LiteralField('', '</div>');
     /* -----------------------------------------
         * Fields
        ------------------------------------------*/
     $firstName = new TextField('FirstName', 'First Name');
     $firstName->setAttribute('required', 'required')->addExtraClass('form-control');
     $lastName = new TextField('LastName', 'Last Name');
     $lastName->setAttribute('required', 'required')->addExtraClass('form-control');
     $email = new EmailField('Email', 'Email Address');
     $email->setAttribute('required', 'required')->addExtraClass('form-control');
     $phone = new TextField('Phone', 'Phone Number (optional)');
     $phone->addExtraClass('form-control');
     $message = new TextareaField('Message', 'Message');
     $message->setAttribute('placeholder', _t('ContactPage.MessagePlaceholder', 'Enter your message'))->setAttribute('required', 'required')->addExtraClass('form-control');
     $question = new TextField('Question', '3 &plus; 7 &equals; ?');
     $question->setAttribute('required', 'required')->addExtraClass('form-control');
     $fields = new FieldList($row, $column, $firstName, $close, $column, $lastName, $close, $close, $row, $column, $email, $close, $column, $phone, $close, $close, $message, $question);
     $action = new FormAction('SendContactForm', _t('ContactPage.SubmitText', 'Submit'));
     $action->addExtraClass('btn btn-primary btn-lg');
     $actions = new FieldList($action);
     $validator = new RequiredFields('FirstName', 'LastName', 'Email', 'Message');
     $form = Form::create($this, 'ContactForm', $fields, $actions, $validator);
     if ($formData = Session::get('FormInfo.Form_ContactForm.data')) {
         $form->loadDataFrom($formData);
     }
     return $form;
 }
 /**
  * Returns a form for editing the attached model
  */
 public function EditForm()
 {
     $fields = $this->currentRecord->getCMSFields();
     $fields->push(new HiddenField("ID"));
     $validator = $this->currentRecord->hasMethod('getCMSValidator') ? $this->currentRecord->getCMSValidator() : new RequiredFields();
     $validator->setJavascriptValidationHandler('none');
     $actions = $this->currentRecord->getCMSActions();
     if ($this->currentRecord->canEdit(Member::currentUser())) {
         $actions->push(new FormAction("doSave", _t('ModelAdmin.SAVE', "Save")));
     } else {
         $fields = $fields->makeReadonly();
     }
     if ($this->currentRecord->canDelete(Member::currentUser())) {
         $actions->insertFirst($deleteAction = new FormAction('doDelete', _t('ModelAdmin.DELETE', 'Delete')));
         $deleteAction->addExtraClass('delete');
     }
     $actions->insertFirst(new FormAction("goBack", _t('ModelAdmin.GOBACK', "Back")));
     $form = new Form($this, "EditForm", $fields, $actions, $validator);
     $form->loadDataFrom($this->currentRecord);
     return $form;
 }
 /**
  * @return Form
  */
 public function DeleteFileForm()
 {
     $form = new Form($this, 'DeleteFileForm', new FieldSet(new HiddenField('DeleteFile', null, false)), new FieldSet($deleteButton = new FormAction('delete', sprintf(_t('FileIFrameField.DELETE', 'Delete %s'), $this->FileTypeName()))));
     $deleteButton->addExtraClass('delete');
     return $form;
 }