当前位置: 首页>>代码示例>>PHP>>正文


PHP Form::saveInto方法代码示例

本文整理汇总了PHP中Form::saveInto方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::saveInto方法的具体用法?PHP Form::saveInto怎么用?PHP Form::saveInto使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Form的用法示例。


在下文中一共展示了Form::saveInto方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: submitFeedback

 function submitFeedback(array $data, Form $form)
 {
     // TRUE if the submission contains a link. Crude spam mitigation.
     $ContainsLink = strpos($data['Content'], "http://") !== false;
     if ($data['Content'] != NULL && !$ContainsLink) {
         $FeedbackSubmission = new FeedbackSubmission();
         $form->saveInto($FeedbackSubmission);
         // Tie the URL of the current page to the feedback submission
         $page = Director::get_current_page();
         $FeedbackSubmission->Page = $page->Link();
         //$FeedbackSubmission->write();
         //Send email alert about submission
         $Subject = "New Website Feedback Submission";
         $email = EmailFactory::getInstance()->buildEmail(FEEDBACK_FORM_FROM_EMAIL, FEEDBACK_FORM_TO_EMAIL, $Subject);
         $email->setTemplate("FeedbackSubmissionEmail");
         $email->populateTemplate($FeedbackSubmission);
         $email->send();
         // Redirect back to the page with a success message
         $form->controller->setMessage('Success', 'Thanks for providing feedback to improve the OpenStack website!');
         $form->controller->redirectBack();
     } else {
         $form->controller->setMessage('Error', "Oops! It doesn't look like you provided any feedback. Please check the form and try again.");
         $form->controller->redirectBack();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:25,代码来源:FeedbackForm.php

示例2: updateworkflow

 /**
  * Update a workflow based on user input. 
  *
  * @todo refactor with WorkflowInstance::updateWorkflow
  * 
  * @param array $data
  * @param Form $form
  * @param SS_HTTPRequest $request
  * @return String
  */
 public function updateworkflow($data, Form $form, $request)
 {
     $svc = singleton('WorkflowService');
     $p = $form->getRecord();
     $workflow = $svc->getWorkflowFor($p);
     $action = $workflow->CurrentAction();
     if (!$p || !$p->canEditWorkflow()) {
         return;
     }
     $allowedFields = $workflow->getWorkflowFields()->saveableFields();
     unset($allowedFields['TransitionID']);
     $allowed = array_keys($allowedFields);
     if (count($allowed)) {
         $form->saveInto($action, $allowed);
         $action->write();
     }
     if (isset($data['TransitionID']) && $data['TransitionID']) {
         $svc->executeTransition($p, $data['TransitionID']);
     } else {
         // otherwise, just try to execute the current workflow to see if it
         // can now proceed based on user input
         $workflow->execute();
     }
     return $this->owner->getResponseNegotiator()->respond($this->owner->getRequest());
 }
开发者ID:normann,项目名称:advancedworkflow,代码行数:35,代码来源:AdvancedWorkflowExtension.php

示例3: Register

 public function Register($data, Form $form)
 {
     if (!Member::currentUser()) {
         $member = new Member();
         // Debug::show($form);
         $form->saveInto($member);
         if (Group::get()->filter('Title', 'Subscribed')->count() == 0) {
             $group = Group::create();
             $group->Title = 'Subscribed';
             $group->write();
         } else {
             $group = Group::get()->filter('Title', 'Subscribed')->First();
         }
         if (Member::get()->filter('Email', $data['Email'])) {
             $form->addErrorMessage('Email', 'That email address is already in use. <a href="Security/login">login</a>', 'bad', true, true);
             //Controller::curr()->redirect('register');
         } else {
             //has to be called before setting group
             $member->write();
             if (!$member->inGroup($group)) {
                 $member->Groups()->add($group);
             }
         }
     }
     Controller::curr()->redirectBack();
 }
开发者ID:vinstah,项目名称:body,代码行数:26,代码来源:RegisterMemberPage.php

示例4: dosave

 /**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:jelicanin-silverstripe-contact-page,代码行数:35,代码来源:ContactInquiryForm.php

示例5: doRegister

 function doRegister($data, Form $form)
 {
     //Check for existing member email address
     if ($member = DataObject::get_one("Member", "`Email` = '" . Convert::raw2sql($data['Email']) . "'")) {
         //Set error message
         $form->sessionMessage($data['Email'] . ". Sorry, that email address already exists. Please choose another.", 'bad');
         //Return back to form
         return $this->redirectBack();
         //return Director::redirectBack();
     } else {
         //Otherwise create new member and log them in
         $Member = new Member();
         $form->saveInto($Member);
         $Member->write();
         $Member->login();
         //Find or create the 'user' group
         if (!($userGroup = DataObject::get_one('Group', "Code = 'users'"))) {
             $userGroup = new Group();
             $userGroup->Code = "users";
             $userGroup->Title = "users";
             $userGroup->Write();
             $userGroup->Members()->add($Member);
         }
         //Add member to user group
         $userGroup->Members()->add($Member);
         //Get profile page
         if ($ProfilePage = DataObject::get_one('EditProfilePage')) {
             //echo "profile page exists";
             //Redirect to profile page with success message
             return $this->redirect($ProfilePage->Link());
         }
     }
 }
开发者ID:helpfulrobot,项目名称:phuongle-silverstripe-member-registration,代码行数:33,代码来源:RegistrationPage.php

示例6: updateRecord

 /**
  * 
  * @param Form $form
  * @return SignatureRecord
  */
 protected function updateRecord(Form $form)
 {
     $signature = $this->getSignatureRecord(true);
     $form->saveInto($signature);
     $signature->write();
     return $signature;
 }
开发者ID:helpfulrobot,项目名称:brrltd-silverstripe-signaturegenerator,代码行数:12,代码来源:SignatureController.php

示例7: save_siteconfig

 /**
  * Save the current sites {@link SiteConfig} into the database
  *
  * @param array $data 
  * @param Form $form 
  * @return String
  */
 public function save_siteconfig($data, $form)
 {
     $siteConfig = SiteConfig::current_site_config();
     $form->saveInto($siteConfig);
     $siteConfig->write();
     $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
     return $this->getResponseNegotiator()->respond($this->request);
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:15,代码来源:CMSSettingsController.php

示例8: rawurlencode

 /**
  * Save the current sites {@link SiteConfig} into the database
  *
  * @param array $data 
  * @param Form $form 
  * @return String
  */
 function save_siteconfig($data, $form)
 {
     $siteConfig = SiteConfig::current_site_config();
     $form->saveInto($siteConfig);
     $siteConfig->write();
     $this->response->addHeader('X-Status', rawurlencode(_t('LeftAndMain.SAVEDUP', 'Saved.')));
     return $form->forTemplate();
 }
开发者ID:nzjoel,项目名称:silverstripe-cms,代码行数:15,代码来源:CMSSettingsController.php

示例9: testFormSaveInto

 public function testFormSaveInto()
 {
     $form = new Form(new Controller(), 'Form', new FieldList($f = new DatetimeField('MyDatetime', null)), new FieldList(new FormAction('doSubmit')));
     $f->setValue(array('date' => '29/03/2003', 'time' => '23:59:38'));
     $m = new DatetimeFieldTest_Model();
     $form->saveInto($m);
     $this->assertEquals('2003-03-29 23:59:38', $m->MyDatetime);
 }
开发者ID:normann,项目名称:sapphire,代码行数:8,代码来源:DatetimeFieldTest.php

示例10: doAdd

 /**
  * Handles adding the snippet to the database
  * @param {array} $data Data submitted by the user
  * @param {Form} $form Form submitted
  */
 public function doAdd($data, Form $form)
 {
     $record = $this->getRecord(null);
     $form->saveInto($record);
     $record->write();
     $editController = singleton('CodeBank');
     $editController->setCurrentPageID($record->ID);
     return $this->redirect(Controller::join_links(singleton('CodeBank')->Link('show'), $record->ID));
 }
开发者ID:helpfulrobot,项目名称:undefinedoffset-silverstripe-codebank,代码行数:14,代码来源:CodeBankAddSnippet.php

示例11: HandleForm

 /**
  * @param array $data
  * @param Form $form
  * @throws ValidationException
  * @throws null
  */
 public function HandleForm($data, $form)
 {
     /** @var Contact $Contact */
     $Contact = Contact::create();
     $form->saveInto($Contact);
     $Contact->write();
     Session::set('ThanksMessage', true);
     $this->redirect($this->Link() . '#section-contact');
 }
开发者ID:silverstripe-europe-meetup,项目名称:website-2015,代码行数:15,代码来源:Page.php

示例12: doSubmit

 function doSubmit(array $raw_data, Form $form)
 {
     $controller = $form->getController();
     $data = Convert::raw2sql($raw_data);
     $submission = new Distributor();
     $form->saveInto($submission);
     $submission->DistributorPageID = $controller->ID;
     $submission->write();
     return $controller->redirect($controller->Link());
 }
开发者ID:helpfulrobot,项目名称:chitosystems-silverstripe-distributor-map,代码行数:10,代码来源:DistributorForm.php

示例13: testLookupFieldDisabledSaving

 public function testLookupFieldDisabledSaving()
 {
     $object = new DataObjectTest_Team();
     $form = new Form(new Controller(), 'Form', new FieldList(new LookupField('Players', 'Players')), new FieldList());
     $form->loadDataFrom(array('Players' => array(14, 18, 22)));
     $form->saveInto($object);
     $playersIds = $object->Players()->getIDList();
     $this->assertTrue($form->validate());
     $this->assertEquals($playersIds, array(), 'saveInto() should not save into the DataObject for the LookupField');
 }
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:10,代码来源:FormTest.php

示例14: save

 /**
  * Updates an existing Member's profile.
  */
 public function save(array $data, Form $form)
 {
     $form->saveInto($this->member);
     try {
         $this->member->write();
     } catch (ValidationException $e) {
         $form->sessionMessage($e->getResult()->message(), 'bad');
         return $this->redirectBack();
     }
     $form->sessionMessage(_t('MemberProfiles.PROFILEUPDATED', 'Your profile has been updated.'), 'good');
     return $this->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:zucchi-membermanagement,代码行数:15,代码来源:MembersAccountPage_Controller.php

示例15: proceed

 /**
  * Save the changes to the form, and redirect to the checkout page
  *
  * @param array          $data
  * @param Form           $form
  * @param SS_HTTPRequest $request
  *
  * @return bool|SS_HTTPResponse
  */
 public function proceed($data, $form, $request)
 {
     $member = Member::currentUser();
     if (!$member) {
         return false;
     }
     $form->saveInto($member);
     $member->write();
     $form->sessionMessage(_t("MemberForm.DetailsSaved", 'Your details have been saved'), 'good');
     $this->extend('updateShopAccountFormResponse', $request, $form, $data, $response);
     return $response ?: $this->getController()->redirect(CheckoutPage::find_link());
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:21,代码来源:ShopAccountForm.php


注:本文中的Form::saveInto方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。