當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ContactForm::getName方法代碼示例

本文整理匯總了PHP中ContactForm::getName方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContactForm::getName方法的具體用法?PHP ContactForm::getName怎麽用?PHP ContactForm::getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ContactForm的用法示例。


在下文中一共展示了ContactForm::getName方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: contactAction

 public function contactAction(array $params)
 {
     //creating form entity
     $form = new ContactForm($_POST);
     //check if we have a flash message in get params
     $flash_msg = isset($params['flash_msg']) ? $params['flash_msg'] : '';
     //if form sent
     if ($_POST) {
         if ($form->validate()) {
             $flash_msg = 'Message sent';
             $email_body = "This is a message from {$form->getName()}, {$form->getEmail()} : {$form->getMessage()}";
             //C:\xampp\mailoutput
             mail('kap0sha@yandex.ru', 'Contact message', $email_body);
             if ($_FILES['attachment']) {
                 $form->uploadAttachment();
             }
         } else {
             $flash_msg = 'Fill in the fields';
         }
         //redirectt
         header("Location: /index.php?controller=index&action=contact&flash_msg={$flash_msg}");
     }
     $data = array('form' => $form, 'message' => $flash_msg);
     return $this->render('contact', $data);
 }
開發者ID:OlehGit,項目名稱:mydemo,代碼行數:25,代碼來源:IndexController.php

示例2: executeContact

 public function executeContact(sfWebRequest $request)
 {
     $route_params = $this->getRoute()->getParameters();
     if (isset($route_params['type']) && $route_params['type'] == 'new') {
         // CREATE
         $target_list = $this->findTargetList();
         /* @var $target_list MailingList */
         if (!$target_list) {
             return $this->notFound();
         }
         if (!$this->getGuardUser()->isTargetListMember($target_list, true)) {
             return $this->noAccess();
         }
         $contact = new Contact();
         $contact->setMailingList($target_list);
         $route = 'target_contact_new';
         $route_params = array('id' => $target_list->getId());
     } else {
         // EDIT
         $contact = ContactTable::getInstance()->find($request->getParameter('id'));
         /* @var $contact Contact */
         if (!$contact) {
             return $this->notFound();
         }
         $target_list = $contact->getMailingList();
         if (!$this->getGuardUser()->isTargetListMember($target_list, true)) {
             return $this->noAccess();
         }
         $route = 'target_contact';
         $route_params = array('id' => $contact->getId(), 'page' => $request->getParameter('page'));
     }
     $form = new ContactForm($contact);
     if ($request->isMethod('post')) {
         $form->bind($request->getPostParameter($form->getName()));
         if ($form->isValid()) {
             $form->save();
             $target_list->state(Doctrine_Record::STATE_DIRTY);
             // to invalidate cache
             $target_list->save();
             $page = $request->getParameter('page');
             if ($page) {
                 return $this->ajax()->replaceWithComponent('#contacts', 'target', 'contacts', array('target_list' => $target_list, 'page' => $page, 'no_filter' => true))->render();
             } else {
                 return $this->ajax()->replaceWithComponent('#contacts', 'target', 'contacts', array('target_list' => $target_list, 'last_page' => true, 'no_filter' => true))->render();
             }
         } else {
             return $this->ajax()->form($form)->render();
         }
     }
     if (!$contact->isNew()) {
         return $this->ajax()->remove('#contact_form_' . $contact->getId())->afterPartial('#contact_' . $contact->getId(), 'contact', array('form' => $form, 'route' => $route, 'route_params' => $route_params))->chosen('#contact_form_' . $contact->getId() . ' select', array('allow_single_deselect' => true))->render();
     } else {
         return $this->ajax()->remove('#contact_form_')->afterPartial('#contacts tbody', 'contact', array('form' => $form, 'route' => $route, 'route_params' => $route_params))->chosen('#contact_form_ select', array('allow_single_deselect' => true))->render();
     }
 }
開發者ID:uniteddiversity,項目名稱:policat,代碼行數:55,代碼來源:actions.class.php


注:本文中的ContactForm::getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。