當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。