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


PHP ContactForm::save方法代码示例

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


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

示例1: actionContact

 public function actionContact()
 {
     $model = new ContactForm();
     if (isset($_POST['ContactForm'])) {
         $model->attributes = $_POST['ContactForm'];
         if ($model->save()) {
             $this->redirect(Yii::app()->homeUrl);
         }
     }
     $this->render('contact', array('model' => $model));
 }
开发者ID:noahkim,项目名称:kowop,代码行数:11,代码来源:SiteController.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

示例3: validate

    }
    public function validate($data)
    {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
    public function save()
    {
        file_put_contents('messages.txt', $this->message, FILE_APPEND);
    }
}
if (isset($_POST['submit'])) {
    $messages = new ContactForm();
    $messages->save();
}
?>
    <form action="<?php 
echo $_SERVER["PHP_SELF"];
?>
" method="post">
        login:<span style="color: red;"><?php 
echo $messages->error;
?>
<br>
        <input type="text" name="login" required></span><br>
        message:<br>
        <textarea name="message" cols="30" rows="10" required></textarea><br><br>
        <input type="submit" name="submit" value="submit">
    </form>
开发者ID:SCARFACET0NY,项目名称:Homework,代码行数:31,代码来源:classContactForm1.php


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