本文整理汇总了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) {
//.........这里部分代码省略.........