本文整理汇总了PHP中FormAction::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP FormAction::setAttribute方法的具体用法?PHP FormAction::setAttribute怎么用?PHP FormAction::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormAction
的用法示例。
在下文中一共展示了FormAction::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PrepaidSignupForm
function PrepaidSignupForm()
{
$cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
$monthArray = array();
for ($i = 1; $i <= 12; $i++) {
$monthArray[$i] = date('F', mktime(0, 0, 0, $i));
}
$yearArray = array();
$currentYear = date('Y');
for ($i = 0; $i <= 10; $i++) {
$yearArray[$currentYear + $i] = $currentYear + $i;
}
$trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
$price = Product::get()->byID(7)->Price;
$shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
$whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
$fields = new FieldList(new LiteralField('SignupTitle', '<h2>Create Your Account</h2>'), new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new LiteralField('BillingInfoTitle', '<h2>Billing Information</h2>'), new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new TextField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
// Create action
$actions = new FieldList($submit = new FormAction('doPrepaidSignup', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
// Create action
$validator = new RequiredFields('Email', 'Password', 'FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'OrderTotal');
$validator = null;
return new Form($this, 'PrepaidSignupForm', $fields, $actions, $validator);
}
示例2: testGetField
public function testGetField()
{
$formAction = new FormAction('test');
$this->assertContains('type="submit"', $formAction->getAttributesHTML());
$formAction->setAttribute('src', 'file.png');
$this->assertContains('type="image"', $formAction->getAttributesHTML());
}
示例3: MemberNonExpiringHeatmapsForm
function MemberNonExpiringHeatmapsForm()
{
// Get current member
$member = Member::currentUser();
$isContactID = $member->ISContactID;
$subscription = $this->getCurrentSubscription($member->ID);
switch ($subscription->Product()->ID) {
case 1:
$productID = 4;
break;
case 2:
$productID = 5;
break;
case 3:
$productID = 6;
break;
}
$price = Product::get()->byID($productID)->Price;
$shoppingCart = $this->renderWith('PrepaidShoppingCart', array('Price' => $price));
// Get existing credit card ID
$creditCard = $this->getCurrentCreditCard($member->ID);
if (!$creditCard) {
$this->setMessage('Error', 'Please update your credit card first.');
return $this->redirect('/account-settings/#tabs-2');
}
$fields = new FieldList(new HiddenField('FirstName', 'First Name', $member->FirstName), new HiddenField('LastName', 'Last Name', $member->Surname), new HiddenField('Company', 'Company(optional)', $creditCard->Company), new HiddenField('StreetAddress1', 'Street Address1', $creditCard->StreetAddress1), new HiddenField('StreetAddress2', 'Street Address2(optional)', $creditCard->StreetAddress2), new HiddenField('City', 'City', $creditCard->City), new HiddenField('State', 'State/Province', $creditCard->State), new HiddenField('PostalCode', 'Zip/Poatal Code', $creditCard->PostalCode), new HiddenField('Country', 'Country', $creditCard->Country), new HiddenField('CreditCardType', 'Credit Card Type', $creditCard->CreditCardType), new HiddenField('NameOnCard', 'Name On Card', $creditCard->NameOnCard), new HiddenField('CreditCardNumber', 'Credit Card Number', $creditCard->CreditCardNumber), new HiddenField('CVVCode', 'Security/CVV Code', $creditCard->CreditCardCVV), new HiddenField('ExpirationMonth', 'Expiration Date', $creditCard->ExpiryMonth), new HiddenField('ExpirationYear', '', $creditCard->ExpiryYear), new LiteralField('ShoppingCart', $shoppingCart), new HiddenField('ProductID', '', $productID), new HiddenField('Price', '', $price), new HiddenField('Quantity', '', 1));
// Create action
$actions = new FieldList($submit = new FormAction('doPurchase', 'Purchase Heatmaps'));
$submit->setAttribute('src', 'themes/attwiz/images/button_purchase.png');
// Create action
$validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear');
return new Form($this, 'MemberNonExpiringHeatmapsForm', $fields, $actions, $validator);
}
示例4: TrialSignupForm
function TrialSignupForm()
{
$cardType = array("visa" => "<img src='themes/attwiz/images/visa.png' height=30px></img>", "mc" => "<img src='themes/attwiz/images/mastercard.jpeg' height=30px></img>", "amex" => "<img src='themes/attwiz/images/ae.jpeg' height=30px></img>", "discover" => "<img src='themes/attwiz/images/discover.jpeg' height=30px></img>");
$monthArray = array();
for ($i = 1; $i <= 12; $i++) {
$monthArray[$i] = date('F', mktime(0, 0, 0, $i));
}
$yearArray = array();
$currentYear = date('Y');
for ($i = 0; $i <= 10; $i++) {
$yearArray[$currentYear + $i] = $currentYear + $i;
}
$trialExpiryDate = date('F-j-Y', mktime(0, 0, 0, date('n') + 1, date('j'), date('Y')));
$subscriptionInfo = "<div id='SubscriptionInfo'><h2>Post-Trial Subscription Selection</h2>\n\t <p>Your 10 heatmaps will expire on {$trialExpiryDate}, at which time your account \n\t will be replenished with a new allocation of heatmap credits according to the \n\t subscription level you choose below. You may cancel your subscription any time \n\t before your trial period ends and your credit card will only be charged 1 dollar.</p></div>";
$subscriptionType = array("1" => "Bronze - (10 heatmaps for \$27.00 / month)", "2" => "Silver - (50 heatmaps for \$97.00 / month)", "3" => "Gold - (200 heatmaps for \$197.00 / month)");
$whatsThis = '<span id="WhatsThis"><a id="WhatsThisImage" href="themes/attwiz/images/cvv.jpg" title="What\'s this?">What\'s this?</a></span>';
$fields = new FieldList(new TextField('FirstName', 'First Name'), new TextField('LastName', 'Last Name'), new TextField('Company', 'Company(optional)'), new TextField('StreetAddress1', 'Street Address1'), new TextField('StreetAddress2', 'Street Address2(optional)'), new TextField('City', 'City'), new TextField('State', 'State/Province'), new TextField('PostalCode', 'Zip/Poatal Code'), new CountryDropdownField('Country'), new OptionsetField('CreditCardType', 'Credit Card Type', $cardType, 'visa'), new TextField('NameOnCard', 'Name On Card'), new NumericField('CreditCardNumber', 'Credit Card Number'), new PasswordField('CVVCode', 'Security/CVV Code'), new LiteralField('WhatIsThis', $whatsThis), new DropdownField('ExpirationMonth', 'Expiration Date', $monthArray), new DropdownField('ExpirationYear', '', $yearArray), new LiteralField('SubscriptionInfo', $subscriptionInfo), new OptionsetField('SubscriptionType', '', $subscriptionType, '1'), new CheckboxField('Agreement', ' I understand that this is a recurring subscription and I will be billed monthly unless I cancel.'));
// Create action
$actions = new FieldList($submit = new FormAction('doSignup', 'Start Trial'));
$submit->setAttribute('src', 'themes/attwiz/images/button_startmytrialnow.gif');
// Create action
$validator = new RequiredFields('FirstName', 'LastName', 'StreetAddress1', 'City', 'State', 'PoatalCode', 'Country', 'CreditCardType', 'NameOnCard', 'CreditCardNumber', 'CVVCode', 'ExpirationMonth', 'ExpirationYear', 'SubscriptionInfo', 'SubscriptionType');
$validator = null;
$form = new Form($this, 'TrialSignupForm', $fields, $actions, $validator);
$data = Session::get("FormInfo.Form_TrialSignupForm.data");
if (is_array($data)) {
$form->loadDataFrom($data);
}
return $form;
}
示例5: Form
/**
* This form is exactly like the CMS form. It gives us an opportunity to test the fields outside of the CMS context
*/
function Form()
{
$fields = $this->getCMSFields();
$actions = new FieldList(new FormAction("save", "Save"), $gohome = new FormAction("gohome", "Go home"));
$gohome->setAttribute('src', 'frameworktest/images/test-button.png');
$form = new Form($this, "Form", $fields, $actions);
$form->loadDataFrom($this->dataRecord);
return $form;
}
示例6: RegistrationForm
function RegistrationForm()
{
$fields = new FieldList(new EmailField('Email', 'Email'), new ConfirmedPasswordField('Password', 'Password'), new CheckboxField('Terms', 'I agree to the <a href="/customer-login/terms-of-use/" target="_blank">AttentionWizard Terms of Use</a>', 1));
// Create action
$actions = new FieldList($submit = new FormAction('doRegister', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button_continue.gif');
// Create action
$validator = new RequiredFields('Email', 'Password');
$form = new Form($this, 'RegistrationForm', $fields, $actions);
//$form->setTemplate('RegistrationForm');
return $form;
}
示例7: CancelSubscriptionForm
function CancelSubscriptionForm()
{
$reasons = array("I didn't use the product as much as I anticipated" => "I didn't use the product as much as I anticipated", "The cost was too high" => "The cost was too high", "I had technical problems generating heatmaps" => "I had technical problems generating heatmaps", "I have changed jobs/careers" => "I have changed jobs/careers", "I had problems with customer service" => "I had problems with customer service", "I didn't find the heatmaps helpful" => "I didn't find the heatmaps helpful", "Other (you may contact us support@attentionwizard.com with additional feedback)" => "Other (you may contact us support@attentionwizard.com with additional feedback)");
$info = '<p>Please remember, you can continue to purchase non-expiring heatmaps and access your heatmap inventory. Your account will remain open and available to you even after your subscription is cancelled.</p>
<p> </p>
<p style="font-style:italic;">Note: accounts with no activity for a 60-day period may be closed, and heatmaps associated with the account purged.If you wish to completely close your account please email <a href="mailto:support@attentionwizard.com">support@attentionwizard.com</a></p>
';
$fields = new FieldList(new CheckboxSetField('Reasons', '', $reasons), new LiteralField('Info', $info));
// Create action
$actions = new FieldList($submit = new FormAction('cancelSubscription', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button_cancel_sub.png');
// Create action
$validator = new RequiredFields('Reasons');
return new Form($this, 'CancelSubscriptionForm', $fields, $actions, $validator);
}
示例8: CreateHeatmapForm
public function CreateHeatmapForm()
{
$includeWatermark = array("1" => "Yes,Include Watermark", "0" => "No,Remove Watermark");
$fields = new FieldList($imageField = new FileField('OriginalImage', 'Upload an Image File'), new LiteralField('UploadInfo', 'Acceptable images are jpg or png, 500-1600 pixels wide by 500-1200 pixels height.<hr>'), new OptionsetField('IncludeWatermark', 'Include Watermark?', $includeWatermark, 1));
$imageField->getValidator()->setAllowedExtensions(array('jpg', 'jpeg', 'png'));
$imageField->setAttribute('class', 'jfilestyle');
$imageField->setAttribute('data-buttonText', "<img src='themes/attwiz/images/button-create-heatmap-browse.jpg'></img>");
$imageField->setAttribute('data-placeholder', 'No file selected..');
// Create action
$actions = new FieldList($submit = new FormAction('processCreateHeatmap', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button-create-heatmap-blue-bg.jpg');
// Create action
$validator = new RequiredFields('OriginalImage', 'IncludeWatermark');
return new Form($this, 'CreateHeatmapForm', $fields, $actions, $validator);
}
示例9: EditProfileForm
function EditProfileForm()
{
//Create our fields
$fields = new FieldList(new TextField('FirstName', 'First Name'), new TextField('Surname', 'Last Name'), new TextField('Email', 'Email'), new ConfirmedPasswordField('Password', 'New Password'));
// Create action
$actions = new FieldList($saveProfileAction = new FormAction('SaveProfile', ''));
$saveProfileAction->setAttribute('src', 'themes/attwiz/images/button_submit.gif');
// Create action
$validator = new RequiredFields('FirstName', 'Surname', 'Email');
$validator = null;
//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;
}
示例10: ContactUsForm
function ContactUsForm()
{
$name = null;
$email = null;
$member = Member::currentUser();
if ($member) {
$name = $member->Name;
$email = $member->Email;
}
$fields = new FieldList(new TextField('Name', 'Name<span>(*)</span>', $name), new TextField('Email', 'Email<span>(*)</span>', $email), new TextField('Phone', 'Phone'), new TextField('Topic', 'Subject<span>(*)</span>'), $message = new TextareaField('Message', 'Message<span>(*)</span>'), new LiteralField('MessageLimit', '<span style="font-size:9px;margin-left:143px;position:relative;top:-15px;">Enter not more than 500 characters.</span>'), new RecaptchaField('MyCaptcha'));
$message->setAttribute('maxlength', '500');
// Create action
$actions = new FieldList($submit = new FormAction('doContact', ''));
$submit->setAttribute('src', 'themes/attwiz/images/button_send.gif');
// Create action
$validator = new RequiredFields('Name', 'Email', 'Topic', 'Message');
$validator = null;
return new Form($this, 'ContactUsForm', $fields, $actions, $validator);
}
示例11: updateCMSActions
public function updateCMSActions(FieldList $actions)
{
$active = $this->workflowService->getWorkflowFor($this->owner);
if (Controller::curr() && Controller::curr()->hasExtension('AdvancedWorkflowExtension')) {
if ($active) {
if ($this->canEditWorkflow()) {
$action = new FormAction('updateworkflow', $active->CurrentAction() ? $active->CurrentAction()->Title : _t('WorkflowApplicable.UPDATE_WORKFLOW', 'Update Workflow'));
$action->setAttribute('data-icon', 'navigation');
$actions->push($action);
}
} else {
$effective = $this->workflowService->getDefinitionFor($this->owner);
if ($effective && $effective->getInitialAction()) {
// we can add an action for starting off the workflow at least
$action = new FormAction('startworkflow', $effective->getInitialAction()->Title);
$action->setAttribute('data-icon', 'navigation');
$actions->push($action);
}
}
}
}
示例12: build
/**
* @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;
}
示例13: Form
public function Form()
{
$form = parent::Form();
if (!$form) {
return;
}
if ($this->ShowButtonsOnTop) {
$form->ShowButtonsOnTop = true;
}
$form->setTemplate('EditableUserDefinedFormControl');
// now add an action for "Save"
$fields = $form->Fields();
// first, lets add any custom Note text that is needed
foreach ($this->Fields() as $editableField) {
if ($editableField instanceof EditableFileField) {
$fields->removeByName($editableField->Name);
continue;
}
$formField = $fields->fieldByName($editableField->Name);
if ($formField && $editableField->getSetting('Note')) {
$title = $formField->Title() . '<span class="userformFieldNote">' . Convert::raw2xml($editableField->getSetting('Note')) . '</span>';
$formField->setTitle($title);
}
}
// lets see if there's a submission that we should be loading into the form
if ($this->submission && $this->submission->ID) {
$this->submission->exposeDataFields();
$form->loadDataFrom($this->submission);
$fields->push(new HiddenField('ResumeID', '', $this->submission->ID));
$workflowState = $this->submission->getWorkflowState();
if ($workflowState !== false) {
$form->addExtraClass("workflow-review");
if ($workflowState == 'Readonly') {
$fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Currently under review</p>'));
$this->readonly = true;
} else {
$fields->unshift(LiteralField::create('workflow_warning', '<p class="message warning">Review via ' . Convert::raw2xml($workflowState) . ' </p>'));
}
}
}
if ($this->readonly) {
$form->makeReadonly();
}
$actions = $form->Actions();
if (!$this->ShowSubmitButton) {
$actions->removeByName('action_process');
} else {
if (strlen($this->SubmitWarning)) {
$submitName = $actions->fieldByName('action_process');
$submitName->setAttribute('data-submitwarning', Convert::raw2att($this->SubmitWarning));
$submitName->addExtraClass('submitwarning');
}
}
if (!$this->readonly) {
if (Member::currentUserID()) {
$actions->push($action = new FormAction('storesubmission', 'Save'));
$action->setAttribute('formnovalidate', 'formnovalidate');
// $actions->push(new FormAction('cancelsubmission', 'Cancel', null, null, 'cancel'));
if ($this->ShowPreviewButton) {
$actions->push($action = new FormAction('previewsubmission', 'Preview'));
$action->setAttribute('formnovalidate', 'formnovalidate');
$actions->push($action = new FormAction('previewpdfsubmission', 'PDF / Print'));
$action->setAttribute('formnovalidate', 'formnovalidate');
}
if ($this->submission && $this->ShowDeleteButton) {
$actions->push($action = new FormAction('cancelsubmission', 'Delete'));
$action->setAttribute('formnovalidate', 'formnovalidate');
}
}
} else {
$form->setActions(ArrayList::create());
}
if ($this->submission && $this->readonly) {
$actions->push(new LiteralField("PrintLink", '<a class="editableFormPDFLink" href="' . $this->submission->PDFLink() . '">Download PDF</a>'));
}
// finally - we want to check if this request is trying to do an action that doesn't care about validation.
// IF we are, then we want to clear the validation for this form
if (!isset($_REQUEST['action_process'])) {
$form->unsetValidator();
}
return $form;
}
示例14: getCMSFields
/**
* @return FieldList
*/
public function getCMSFields()
{
$fields = new FieldList(new TabSet('Root'));
$project = $this->Project();
if ($project && $project->exists()) {
$viewerGroups = $project->Viewers();
$groups = $viewerGroups->sort('Title')->map()->toArray();
$members = array();
foreach ($viewerGroups as $group) {
foreach ($group->Members()->map() as $k => $v) {
$members[$k] = $v;
}
}
asort($members);
} else {
$groups = array();
$members = array();
}
// Main tab
$fields->addFieldsToTab('Root.Main', array(TextField::create('ProjectName', 'Project')->setValue(($project = $this->Project()) ? $project->Name : null)->performReadonlyTransformation(), TextField::create('Name', 'Environment name')->setDescription('A descriptive name for this environment, e.g. staging, uat, production'), $this->obj('Usage')->scaffoldFormField('Environment usage'), TextField::create('URL', 'Server URL')->setDescription('This url will be used to provide the front-end with a link to this environment'), TextField::create('Filename')->setDescription('The capistrano environment file name')->performReadonlyTransformation()));
// Backend identifier - pick from a named list of configurations specified in YML config
$backends = $this->config()->get('allowed_backends', Config::FIRST_SET);
// If there's only 1 backend, then user selection isn't needed
if (sizeof($backends) > 1) {
$fields->addFieldToTab('Root.Main', DropdownField::create('BackendIdentifier', 'Deployment backend')->setSource($backends)->setDescription('What kind of deployment system should be used to deploy to this environment'));
}
$fields->addFieldsToTab('Root.UserPermissions', array($this->buildPermissionField('ViewerGroups', 'Viewers', $groups, $members)->setTitle('Who can view this environment?')->setDescription('Groups or Users who can view this environment'), $this->buildPermissionField('DeployerGroups', 'Deployers', $groups, $members)->setTitle('Who can deploy?')->setDescription('Groups or Users who can deploy to this environment'), $this->buildPermissionField('TickAllSnapshotGroups', 'TickAllSnapshot', $groups, $members)->setTitle("<em>All snapshot permissions</em>")->addExtraClass('tickall')->setDescription('UI shortcut to select all snapshot-related options - not written to the database.'), $this->buildPermissionField('CanRestoreGroups', 'CanRestoreMembers', $groups, $members)->setTitle('Who can restore?')->setDescription('Groups or Users who can restore archives from Deploynaut into this environment'), $this->buildPermissionField('CanBackupGroups', 'CanBackupMembers', $groups, $members)->setTitle('Who can backup?')->setDescription('Groups or Users who can backup archives from this environment into Deploynaut'), $this->buildPermissionField('ArchiveDeleterGroups', 'ArchiveDeleters', $groups, $members)->setTitle('Who can delete?')->setDescription("Groups or Users who can delete archives from this environment's staging area."), $this->buildPermissionField('ArchiveUploaderGroups', 'ArchiveUploaders', $groups, $members)->setTitle('Who can upload?')->setDescription('Users who can upload archives linked to this environment into Deploynaut.<br />' . 'Linking them to an environment allows limiting download permissions (see below).'), $this->buildPermissionField('ArchiveDownloaderGroups', 'ArchiveDownloaders', $groups, $members)->setTitle('Who can download?')->setDescription(<<<PHP
Users who can download archives from this environment to their computer.<br />
Since this implies access to the snapshot, it is also a prerequisite for restores
to other environments, alongside the "Who can restore" permission.<br>
Should include all users with upload permissions, otherwise they can't download
their own uploads.
PHP
), $this->buildPermissionField('PipelineApproverGroups', 'PipelineApprovers', $groups, $members)->setTitle('Who can approve pipelines?')->setDescription('Users who can approve waiting deployment pipelines.'), $this->buildPermissionField('PipelineCancellerGroups', 'PipelineCancellers', $groups, $members)->setTitle('Who can cancel pipelines?')->setDescription('Users who can cancel in-progess deployment pipelines.')));
// The Main.DeployConfig
if ($this->Project()->exists()) {
$this->setDeployConfigurationFields($fields);
}
// The DataArchives
$dataArchiveConfig = GridFieldConfig_RecordViewer::create();
$dataArchiveConfig->removeComponentsByType('GridFieldAddNewButton');
if (class_exists('GridFieldBulkManager')) {
$dataArchiveConfig->addComponent(new GridFieldBulkManager());
}
$dataArchive = GridField::create('DataArchives', 'Data Archives', $this->DataArchives(), $dataArchiveConfig);
$fields->addFieldToTab('Root.DataArchive', $dataArchive);
// Pipeline templates
$this->setPipelineConfigurationFields($fields);
// Pipelines
if ($this->Pipelines()->Count()) {
$pipelinesConfig = GridFieldConfig_RecordEditor::create();
$pipelinesConfig->removeComponentsByType('GridFieldAddNewButton');
if (class_exists('GridFieldBulkManager')) {
$pipelinesConfig->addComponent(new GridFieldBulkManager());
}
$pipelines = GridField::create('Pipelines', 'Pipelines', $this->Pipelines(), $pipelinesConfig);
$fields->addFieldToTab('Root.Pipelines', $pipelines);
}
// Deployments
$deploymentsConfig = GridFieldConfig_RecordEditor::create();
$deploymentsConfig->removeComponentsByType('GridFieldAddNewButton');
if (class_exists('GridFieldBulkManager')) {
$deploymentsConfig->addComponent(new GridFieldBulkManager());
}
$deployments = GridField::create('Deployments', 'Deployments', $this->Deployments(), $deploymentsConfig);
$fields->addFieldToTab('Root.Deployments', $deployments);
Requirements::javascript('deploynaut/javascript/environment.js');
// Add actions
$action = new FormAction('check', 'Check Connection');
$action->setUseButtonTag(true);
$dataURL = Director::absoluteBaseURL() . 'naut/api/' . $this->Project()->Name . '/' . $this->Name . '/ping';
$action->setAttribute('data-url', $dataURL);
$fields->insertBefore($action, 'Name');
// Allow extensions
$this->extend('updateCMSFields', $fields);
return $fields;
}
示例15: GatewayDataForm
/**
* Form for collecting gateway data.
*/
public function GatewayDataForm()
{
$payment = $this->getCurrentPayment();
if (!$payment) {
//redirect if there is no payment object available
return $this->redirect($this->Link());
}
$factory = new GatewayFieldsFactory($payment->Gateway);
$fields = $factory->getFields();
//TODO: never let CC details be stored in session (e.g. validation)
//TODO: force requirement of SSL on live sites
$actions = new FieldList($cancelaction = new FormAction("cancel", _t("PaymentController.DIFFERENTMETHOD", "Choose Different Method")), $payaction = new FormAction("pay", _t("PaymentController.DIFFERENTMETHOD", "Make Payment")));
$cancelaction->setAttribute("formnovalidate", "formnovalidate");
$validator = new RequiredFields(GatewayInfo::required_fields($payment->Gateway));
$form = new Form($this, "GatewayDataForm", $fields, $actions, $validator);
$this->extend('updateGatewayDataForm', $form);
//allow cancel action to run without validation
if (!empty($_REQUEST['action_cancel'])) {
$form->unsetValidator();
}
return $form;
}