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


PHP FOFModel::preprocessForm方法代码示例

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


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

示例1: preprocessForm

 /**
  * Method to allow derived classes to preprocess the form.
  *
  * @param   FOFForm  &$form  A FOFForm object.
  * @param   mixed    &$data  The data expected for the form.
  * @param   string   $group  The name of the plugin group to import (defaults to "content").
  *
  * @return  void
  *
  * @see     FOFFormField
  * @since   2.0
  * @throws  Exception if there is an error in the form event.
  */
 protected function preprocessForm(FOFForm &$form, &$data, $group = 'content')
 {
     // Do what have to be done
     parent::preprocessForm($form, $data, $group);
     $formName = $this->getState('form_name');
     if ($formName == 'form.form' || $formName == 'form.item') {
         $isAdmin = FOFPlatform::getInstance()->isBackend();
         $params = JComponentHelper::getParams('com_babioonevent');
         // Handele enabled field access
         if (!$isAdmin || $this->input->getCmd('task') == 'edit' && !$isAdmin) {
             $this->removeFields($form, 'enabled');
         }
         if ($isAdmin) {
             // Change the field type for the backend, use the "normal" datepicker
             $form->setFieldAttribute('sdate', 'type', 'calendar');
             $form->setFieldAttribute('sdate', 'format', '%d.%m.%Y');
             $form->setFieldAttribute('edate', 'type', 'calendar');
             $form->setFieldAttribute('edate', 'format', '%d.%m.%Y');
         }
         // Handle the date and time fields
         $showdates = $params->get('showdates', 4);
         $remove = array('stimehh', 'stimemm', 'edate', 'etimehh', 'etimemm');
         $required = array();
         if (!in_array($showdates, array(1, 3, 6, 9, 14))) {
             $offset = array_search('stimehh', $remove);
             array_splice($remove, array_search('stimehh', $remove), 1);
             array_splice($remove, array_search('stimemm', $remove), 1);
         }
         if ($showdates > 5) {
             array_splice($remove, array_search('edate', $remove), 1);
         }
         if (in_array($showdates, array(8, 12, 13, 17, 18, 19))) {
             array_splice($remove, array_search('etimehh', $remove), 1);
             array_splice($remove, array_search('etimemm', $remove), 1);
         }
         if (in_array($showdates, array(3, 4, 5)) || $showdates > 8) {
             $required[] = 'sdate';
         }
         if (in_array($showdates, array(5, 11, 13, 16, 18, 19))) {
             $required[] = 'stimehh';
             $required[] = 'stimemm';
         }
         if ($showdates > 13) {
             $required[] = 'edate';
         }
         if ($showdates == 19) {
             $required[] = 'etimehh';
             $required[] = 'etimemm';
         }
         $this->removeFields($form, $remove);
         $this->setFieldsRequired($form, $required);
         $fields = array('organiser' => 2, 'contact' => 1, 'phone' => 1, 'website' => 1, 'email' => 1, 'shortdesc' => 1, 'longdesc' => 1);
         foreach ($fields as $fieldname => $defaultvalue) {
             $this->manageField($form, $fieldname, $params->get('show' . $fieldname, $defaultvalue));
         }
         // Remove checkbox showemail when email is disabled
         if ($params->get('showemail', 1) == 0) {
             $this->removeFields($form, 'showemail');
         }
         // Change editor to textbox when frontend
         if (!$isAdmin) {
             $form->setFieldAttribute('teaser', 'type', 'textarea');
             $form->setFieldAttribute('text', 'type', 'textarea');
         }
         // Location fields
         $showlocation = $params->get('showlocation', 2);
         $locDetails = array('ainfo', 'street', 'pcode', 'city', 'state', 'country');
         if ($showlocation == 0) {
             $this->removeFields($form, 'address');
             foreach ($locDetails as $field) {
                 $this->removeFields($form, $locDetails);
             }
         } else {
             if ($showlocation > 2) {
                 $this->removeFields($form, 'address');
                 if ($showlocation > 3) {
                     $this->setFieldsRequired($form, array_slice($locDetails, 1));
                 }
             } else {
                 $this->removeFields($form, $locDetails);
                 if ($showlocation == 2) {
                     $this->setFieldsRequired($form, 'address');
                 }
             }
         }
         // Manage charge fields
         if ($params->get('showcharge', 2) == 0) {
//.........这里部分代码省略.........
开发者ID:rdeutz,项目名称:babioon-event,代码行数:101,代码来源:events.php


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