本文整理汇总了PHP中JForm::removeField方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::removeField方法的具体用法?PHP JForm::removeField怎么用?PHP JForm::removeField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::removeField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onContentPrepareForm
/**
*
* Enter description here ...
* @param JForm $form
* @param unknown $data
*/
function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$this->template = $this->getTemplateName();
if ($this->template && ($app->isAdmin() && $form->getName() == 'com_templates.style' || $app->isSite() && ($form->getName() == 'com_config.templates' || $form->getName() == 'com_templates.style'))) {
jimport('joomla.filesystem.path');
//JForm::addFormPath( dirname(__FILE__) . DS. 'includes' . DS .'assets' . DS . 'admin' . DS . 'params');
$plg_file = JPath::find(dirname(__FILE__) . DS . 'includes' . DS . 'assets' . DS . 'admin' . DS . 'params', 'template.xml');
$tpl_file = JPath::find(JPATH_ROOT . DS . 'templates' . DS . $this->template, 'templateDetails.xml');
if (!$plg_file) {
return false;
}
if ($tpl_file) {
$form->loadFile($plg_file, false, '//form');
$form->loadFile($tpl_file, false, '//config');
} else {
$form->loadFile($plg_file, false, '//form');
}
if ($app->isSite()) {
$jmstorage_fields = $form->getFieldset('jmstorage');
foreach ($jmstorage_fields as $name => $field) {
$form->removeField($name, 'params');
}
$form->removeField('config', 'params');
}
if ($app->isAdmin()) {
$doc->addStyleDeclaration('#jm-ef3plugin-info, .jm-row > .jm-notice {display: none !important;}');
}
}
}
示例2: preprocessForm
protected function preprocessForm(\JForm $form, $data, $group = 'content')
{
// if no data, grab the posted form data.
if (!$data instanceof JObject) {
$data = JFactory::getApplication()->input->get('jform', $data, 'array');
$data = JArrayHelper::toObject($data);
}
$params = new JRegistry();
$params->loadArray($data->params);
if ($params->get('discovery.url')) {
$plugin = $params->get('discovery.type');
$language = JFactory::getLanguage();
$language->load('plg_harvest_' . $plugin);
$path = JPATH_ROOT . '/plugins/harvest/' . $plugin . '/forms/harvest.xml';
$form->loadFile($path, false);
foreach (JPluginHelper::getPlugin('ingest') as $plugin) {
$language->load('plg_ingest_' . $plugin->name);
$path = JPATH_ROOT . '/plugins/ingest/' . $plugin->name . '/forms/ingest.xml';
$form->loadFile($path, false);
}
$form->removeField('originating_url');
$form->removeField('harvester');
// hide the run_once value (users cannot set it after discovery)
$form->setFieldAttribute("run_once", 'type', 'hidden');
$form->setFieldAttribute("run_once", 'class', '');
} else {
$form->removeField('state');
$form->removeField('harvested');
$form->removeField('url', 'params.discovery');
$form->removeField('type', 'params.discovery');
}
parent::preprocessForm($form, $data, $group);
}
示例3: preprocessForm
/**
* Override preprocessForm to load the user plugin group instead of content.
*
* @param object A form object.
* @param mixed The data expected for the form.
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $group = 'user')
{
$userParams = JComponentHelper::getParams('com_users');
// Deal with captcha
$captcha = $userParams->get('captcha', '0');
$captchaRemind = $userParams->get('allowCaptchaUserRemind', '0');
if ($captcha === '0') {
$form->removeField('captcha');
} else {
if ($captchaRemind === '0') {
$form->removeField('captcha');
} else {
$form->setFieldAttribute('captcha', 'plugin', $captcha);
}
}
parent::preprocessForm($form, $data, 'user');
}
示例4: onPrepareUserProfileForm
/**
* @param int $userId The user id
* @param JForm $form
*
* @return boolean
*/
function onPrepareUserProfileForm($userId, &$form)
{
// Add the profile fields to the form.
JForm::addFormPath(dirname(__FILE__) . DS . 'profiles');
$form->load('profile', true, false);
// Toggle whether the address1 field is required.
if ($this->params->get('profile-require_address1', 1) > 0) {
$form->setFieldAttribute('address1', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('address1', 'profile');
}
// Toggle whether the address2 field is required.
if ($this->params->get('profile-require_address2', 1) > 0) {
$form->setFieldAttribute('address2', 'required', $this->params->get('profile-require_address2') == 2, 'profile');
} else {
$form->removeField('address2', 'profile');
}
// Toggle whether the city field is required.
if ($this->params->get('profile-require_city', 1) > 0) {
$form->setFieldAttribute('city', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('city', 'profile');
}
// Toggle whether the region field is required.
if ($this->params->get('profile-require_region', 1) > 0) {
$form->setFieldAttribute('region', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('region', 'profile');
}
// Toggle whether the country field is required.
if ($this->params->get('profile-require_country', 1) > 0) {
$form->setFieldAttribute('country', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('country', 'profile');
}
// Toggle whether the postal code field is required.
if ($this->params->get('profile-require_postal_code', 1) > 0) {
$form->setFieldAttribute('postal_code', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('postal_code', 'profile');
}
// Toggle whether the phone field is required.
if ($this->params->get('profile-require_phone', 1) > 0) {
$form->setFieldAttribute('phone', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('phone', 'profile');
}
// Toggle whether the website field is required.
if ($this->params->get('profile-require_website', 1) > 0) {
$form->setFieldAttribute('website', 'required', $this->params->get('profile-require_address1') == 2, 'profile');
} else {
$form->removeField('website', 'profile');
}
return true;
}
示例5: onContentPrepareForm
function onContentPrepareForm(JForm $form, $data)
{
$name = $form->getName();
if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
return true;
}
// Add the extra fields
JForm::addFormPath(dirname(__FILE__) . '/profiles');
$form->loadFile('profile', false);
// If we're admin we can do some extra things
if ($name != "com_users.user") {
$form->setFieldAttribute("programmename", "readonly", true, "swg_extras");
// $form->setFieldAttrib("leaderid", "readonly", )
$form->removeField("leaderid", "swg_extras");
$form->removeField("leadersetup", "swg_extras");
}
return true;
}
示例6: preprocessForm
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
$template = $this->getState('template.template');
$lang = JFactory::getLanguage();
$template_path = COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . $template;
jimport('joomla.filesystem.path');
$formFile = JPath::clean($template_path . DIRECTORY_SEPARATOR . 'template.xml');
// Load the core and/or local language file(s).
$lang->load('tpl_' . $template, $template_path, null, false, true) || $lang->load('tpl_' . $template, $template_path . '/templates/' . $template, null, false, true);
$default_directory = 'components' . DIRECTORY_SEPARATOR . 'com_tz_portfolio_plus' . DIRECTORY_SEPARATOR . 'templates';
$directory = $default_directory . DIRECTORY_SEPARATOR . $template . DIRECTORY_SEPARATOR . 'html';
if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $directory)) {
$form->setFieldAttribute('layout', 'directory', $directory, 'params');
} elseif (is_array($data) && array_key_exists('protected', $data) && $data['protected'] == 1 || is_object($data) && isset($data->protected) && $data->protected == 1) {
$form->removeField('layout', 'params');
} else {
$form->removeField('layout', 'params');
}
if (file_exists($formFile)) {
// Get the template form.
if (!$form->loadFile($formFile, false, '//config')) {
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
}
// Disable home field if it is default style
if (is_array($data) && array_key_exists('home', $data) && $data['home'] == '1' || is_object($data) && isset($data->home) && $data->home == '1') {
$form->setFieldAttribute('home', 'readonly', 'true');
}
// Attempt to load the xml file.
if (!($xml = simplexml_load_file($formFile))) {
throw new Exception(JText::_('JERROR_LOADFILE_FAILED'));
}
// Get the help data from the XML file if present.
$help = $xml->xpath('/extension/help');
if (!empty($help)) {
$helpKey = trim((string) $help[0]['key']);
$helpURL = trim((string) $help[0]['url']);
$this->helpKey = $helpKey ? $helpKey : $this->helpKey;
$this->helpURL = $helpURL ? $helpURL : $this->helpURL;
}
// Trigger the default form events.
parent::preprocessForm($form, $data, $group);
}
示例7: display
/**
* Display method
*
* @param string $tpl The template name
*
* @return void
*/
public function display($tpl = null)
{
$model = $this->getModel();
$app = JFactory::getApplication();
$this->contentElementName = RedcoreHelpersTranslation::getCurrentContentElement();
$this->componentName = $app->input->get->get('component', $model->getState('filter.component', ''));
$this->activeFilters = $model->getActiveFilters();
$this->state = $model->getState();
$this->filterForm = $model->getForm();
$this->pagination = $model->getPagination();
if (!empty($this->contentElementName)) {
$this->translationTable = RedcoreHelpersTranslation::getTranslationTable();
$this->contentElement = RTranslationHelper::getContentElement($this->translationTable->option, $this->translationTable->xml);
$this->items = $model->getItems();
$this->filterForm->removeField('component', 'filter');
} else {
/** @var RedcoreModelConfig $modelConfig */
$modelConfig = RModelAdmin::getAdminInstance('Config', array('ignore_request' => true), 'com_redcore');
if (!empty($this->componentName)) {
$this->component = $modelConfig->getComponent($this->componentName);
}
$this->contentElements = $modelConfig->loadContentElements($this->componentName);
$this->missingContentElements = $modelConfig->loadMissingContentElements($this->componentName, $this->contentElements);
$this->return = base64_encode('index.php?option=com_redcore&view=translations&contentelement=&component=' . $this->componentName);
$layout = 'manage';
$this->setLayout($layout);
$app->input->set('layout', $layout);
$this->filterForm->removeField('language', 'filter');
$this->filterForm->removeField('search_translations', 'filter');
$this->filterForm->removeField('translations_limit', 'list');
$this->filterForm->removeField('contentelement', 'filter');
}
// Check if option is enabled
if (RBootstrap::getConfig('enable_translations', 0) == 0) {
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_REDCORE_CONFIG_TRANSLATIONS_PLUGIN_LABEL_WARNING', '<a href="index.php?option=com_plugins&view=plugins&filter_search=redcore">' . JText::_('COM_REDCORE_CONFIGURE') . '</a>'), 'error');
}
parent::display($tpl);
}
示例8: preprocessForm
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_djcatalog2');
$user = JFactory::getUser();
$switchable_fields = array('contact_phone', 'contact_street', 'contact_city', 'contact_zip', 'contact_country', 'contact_company_name', 'contact_email_copy');
foreach ($switchable_fields as $field_name) {
if ($params->get($field_name . '_field', '0') == '0') {
$form->removeField($field_name);
} else {
if ($params->get($field_name . '_field', '0') == '2') {
$form->setFieldAttribute($field_name, 'required', 'required');
$form->setFieldAttribute($field_name, 'class', $form->getFieldAttribute($field_name, 'class') . ' required');
}
}
}
$plugin = JFactory::getApplication()->getParams()->get('contact_captcha', JFactory::getConfig()->get('captcha'));
if ($user->id > 0 || ($plugin === 0 || $plugin === '0' || $plugin === '' || $plugin === null)) {
$form->removeField('captcha');
} else {
$form->setFieldAttribute('captcha', 'plugin', $plugin, 'captcha');
}
}
示例9: onContentPrepareForm
/**
* Adds additional fields to the user editing form
*
* @param JForm $form The form to be altered.
* @param mixed $data The associated data for the form.
*
* @return boolean
*/
public function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// We only work with com_users.* and com_admin.profile:
$form_name = $form->getName();
if (!in_array($form_name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
return true;
}
//JLog::add("onContentPrepareForm ".htmlentities($form_name));
$app = JFactory::getApplication();
if ($app->isSite() && $form_name == 'com_users.registration') {
$lang = JFactory::getLanguage()->getTag();
$form->removeField("email2");
$grpoptions = "";
foreach (explode(",", $this->params->get('altgroups')) as $grp) {
$grp = htmlentities(trim($grp));
$grpoptions .= " <option value=\"{$grp}\">" . ($lang == "ru-RU" ? "Я -" : "I'm") . " {$grp}</option>\n";
}
/* Append "altgroup.groupname" field to "default" fieldset
* so that it would be rendered in the same "block" as
* core user fields like "username/email/password": */
$form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="default">' . ' <field name="groupname" type="radio"' . ' label=' . ($lang == "ru-RU" ? '"Кто вы?"' : '"Who are you?"') . ' required="true">' . $grpoptions . ' </field>' . ' </fieldset>' . ' </fields>' . '</form>');
/* JLog::add("input=".self::_str(
$form->getInput("groupname", "altgroup")));
JLog::add("form=".self::_str($form));*/
} elseif ($form_name == 'com_users.profile') {
$lang = JFactory::getLanguage()->getTag();
$form->removeField("email2");
$group_names = array();
if (isset($data->altgroup['groups'])) {
foreach ($data->altgroup['groups'] as $g) {
$group_names[] = $g[1];
}
}
/* Append "altgroup.groupnames" field to "core"
* fieldset: */
$form->load('<form>' . ' <fields name="altgroup">' . ' <fieldset name="core">' . ' <field name="groupnames" type="text"' . ' disabled="true"' . ' label=' . ($lang == "ru-RU" ? '"Вы:"' : '"You are:"') . ' default="' . htmlentities(implode(", ", $group_names)) . '"' . ' />' . ' </fieldset>' . ' </fields>' . '</form>');
}
return true;
}
示例10: preprocessForm
/**
* Method to allow derived classes to preprocess the form.
*
* @param object A form object.
* @param mixed The data expected for the form.
* @param string The name of the plugin group to import (defaults to "content").
* @throws Exception if there is an error in the form event.
* @since 1.6
*/
protected function preprocessForm(JForm $form, $data, $group = 'user')
{
$userParams = JComponentHelper::getParams('com_users');
// Deal with captcha
$captcha = $userParams->get('captcha', '0');
$captchaLogin = $userParams->get('allowCaptchaUserLogin', '0');
if ($captcha === '0') {
$form->removeField('captcha');
} else {
if ($captchaLogin === '0') {
$form->removeField('captcha');
} else {
$form->setFieldAttribute('captcha', 'plugin', $captcha);
}
}
// Import the approriate plugin group.
JPluginHelper::importPlugin($group);
// Get the dispatcher.
$dispatcher = JDispatcher::getInstance();
// Trigger the form preparation event.
$results = $dispatcher->trigger('onContentPrepareForm', array($form, $data));
// Check for errors encountered while preparing the form.
if (count($results) && in_array(false, $results, true)) {
// Get the last error.
$error = $dispatcher->getError();
// Convert to a JException if necessary.
if (!$error instanceof Exception) {
throw new Exception($error);
}
}
}
示例11: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
function onContentPrepareForm($form, $data)
{
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
$name = $form->getName();
if (!in_array($name, array('com_admin.profile', 'com_users.user', 'com_users.profile', 'com_users.registration'))) {
return true;
}
$lang = JFactory::getLanguage();
$lang->load('plg_user_profile', JPATH_ADMINISTRATOR);
$lang->load('mod_improved_ajax_login');
// Add the registration fields to the form.
$db = JFactory::getDBO();
$db->setQuery('SELECT fields FROM #__offlajn_forms WHERE id = 1');
$res = $db->loadObject();
$fields = json_decode($res->fields);
function getAttr($obj, $name)
{
$name = 'jform[elem_' . $name . ']';
return isset($obj->{$name}) ? $obj->{$name} : null;
}
$xml = '<form><fields name="improved"><fieldset name="improved" label="PLG_USER_PROFILE_SLIDER_LABEL"></fieldset></fields></form>';
$profile = JFactory::getXML($xml, false);
foreach ($fields->page as $page) {
foreach ($page->elem as $elem) {
$type = getAttr($elem, 'type');
$name = getAttr($elem, 'name');
if (!isset($type->profile) || $name->value == 'newsletter') {
continue;
}
$field = $profile->fields->fieldset->addChild('field');
$field->addAttribute('name', $name->value ? $name->value : $name->placeholder);
$field->addAttribute('id', 'ial-' . getAttr($elem, 'name')->value);
$field->addAttribute('type', isset($type->defaultValue) ? $type->defaultValue : $type->value);
$field->addAttribute('required', getAttr($elem, 'required')->checked ? 'true' : 'false');
$label = getAttr($elem, 'label');
if ($label) {
$field->addAttribute('label', JText::_($label->value ? $label->value : (@$label->defaultValue ? @$label->defaultValue : @$label->placeholder)));
}
$title = getAttr($elem, 'title');
if ($label) {
$field->addAttribute('description', JText::_($title->value ? $title->value : @$title->defaultValue));
}
$error = getAttr($elem, 'error');
if ($error) {
$field->addAttribute('message', JText::_($error->value ? $error->value : $error->defaultValue));
}
if ($type->value == 'checkbox') {
$field->addAttribute('value', 'on');
}
if ($type->value == 'select') {
$field['type'] = 'list';
$xml = str_replace(array('[', ']'), array('<', '>'), $options = getAttr($elem, 'select')->value);
$opts = JFactory::getXML("<select>{$xml}</select>", false);
foreach ($opts as $opt) {
$option = $field->addChild('option');
$option->addAttribute('value', $opt['value']);
$option[0] = (string) $opt;
}
}
$article = getAttr($elem, 'article');
if ($article) {
$field->addAttribute('article', $article->value);
$option = $field->addChild('option');
$option->addAttribute('value', 'on');
$option[0] = 'JYES';
}
}
}
$form->load($profile, false);
if ($name != 'com_users.registration') {
// We only want the TOS in the registration form
$form->removeField('tos', 'improved');
}
return true;
}
示例12: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
function onContentPrepareForm($form, $data)
{
// Load user_profile plugin language
$lang = JFactory::getLanguage();
$lang->load('plg_user_profile', JPATH_ADMINISTRATOR);
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
if (!in_array($form->getName(), array('com_admin.profile', 'com_users.user', 'com_users.registration', 'com_users.profile'))) {
return true;
}
// Add the registration fields to the form.
JForm::addFormPath(dirname(__FILE__) . '/profiles');
$form->loadFile('profile', false);
// Toggle whether the address1 field is required.
if ($this->params->get('register-require_address1', 1) > 0) {
$form->setFieldAttribute('address1', 'required', $this->params->get('register-require_address1') == 2, 'profile');
} else {
$form->removeField('address1', 'profile');
}
// Toggle whether the address2 field is required.
if ($this->params->get('register-require_address2', 1) > 0) {
$form->setFieldAttribute('address2', 'required', $this->params->get('register-require_address2') == 2, 'profile');
} else {
$form->removeField('address2', 'profile');
}
// Toggle whether the city field is required.
if ($this->params->get('register-require_city', 1) > 0) {
$form->setFieldAttribute('city', 'required', $this->params->get('register-require_city') == 2, 'profile');
} else {
$form->removeField('city', 'profile');
}
// Toggle whether the region field is required.
if ($this->params->get('register-require_region', 1) > 0) {
$form->setFieldAttribute('region', 'required', $this->params->get('register-require_region') == 2, 'profile');
} else {
$form->removeField('region', 'profile');
}
// Toggle whether the country field is required.
if ($this->params->get('register-require_country', 1) > 0) {
$form->setFieldAttribute('country', 'required', $this->params->get('register-require_country') == 2, 'profile');
} else {
$form->removeField('country', 'profile');
}
// Toggle whether the postal code field is required.
if ($this->params->get('register-require_postal_code', 1) > 0) {
$form->setFieldAttribute('postal_code', 'required', $this->params->get('register-require_postal_code') == 2, 'profile');
} else {
$form->removeField('postal_code', 'profile');
}
// Toggle whether the phone field is required.
if ($this->params->get('register-require_phone', 1) > 0) {
$form->setFieldAttribute('phone', 'required', $this->params->get('register-require_phone') == 2, 'profile');
} else {
$form->removeField('phone', 'profile');
}
// Toggle whether the website field is required.
if ($this->params->get('register-require_website', 1) > 0) {
$form->setFieldAttribute('website', 'required', $this->params->get('register-require_website') == 2, 'profile');
} else {
$form->removeField('website', 'profile');
}
// Toggle whether the favoritebook field is required.
if ($this->params->get('register-require_favoritebook', 1) > 0) {
$form->setFieldAttribute('favoritebook', 'required', $this->params->get('register-require_favoritebook') == 2, 'profile');
} else {
$form->removeField('favoritebook', 'profile');
}
// Toggle whether the aboutme field is required.
if ($this->params->get('register-require_aboutme', 1) > 0) {
$form->setFieldAttribute('aboutme', 'required', $this->params->get('register-require_aboutme') == 2, 'profile');
} else {
$form->removeField('aboutme', 'profile');
}
// Toggle whether the tos field is required.
if ($this->params->get('register-require_tos', 1) > 0) {
$form->setFieldAttribute('tos', 'required', $this->params->get('register-require_tos') == 2, 'profile');
} else {
$form->removeField('tos', 'profile');
}
// Toggle whether the dob field is required.
if ($this->params->get('register-require_dob', 1) > 0) {
$form->setFieldAttribute('dob', 'required', $this->params->get('register-require_dob') == 2, 'profile');
} else {
$form->removeField('dob', 'profile');
}
return true;
}
示例13: preprocessForm
protected function preprocessForm(JForm $form, $data, $group = 'content')
{
$app = JFactory::getApplication();
$params = JComponentHelper::getParams('com_djcatalog2');
$user = JFactory::getUser();
$allowed_categories = $params->get('fed_allowed_categories', array());
JArrayHelper::toInteger($allowed_categories);
if (!empty($allowed_categories)) {
$form->setFieldAttribute('cat_id', 'allowed_categories', implode(',', $allowed_categories));
}
if ($params->get('fed_multiple_categories', '0') == '0') {
$form->removeField('categories');
} else {
if (!empty($allowed_categories)) {
$form->setFieldAttribute('categories', 'allowed_categories', implode(',', $allowed_categories));
}
if ((int) $params->get('fed_multiple_categories_limit', 3) > 0) {
$form->setFieldAttribute('categories', 'limit', (int) $params->get('fed_multiple_categories_limit', 3));
if (!empty($data->cat_id)) {
$form->setFieldAttribute('categories', 'ignored_values', $data->cat_id);
}
} else {
if ($params->get('fed_multiple_categories_limit', 3) == '0') {
$form->removeField('categories');
}
}
}
if ($params->get('fed_producer', '0') == '0') {
$form->removeField('producer_id');
} else {
if ($params->get('fed_producer', '0') == '2') {
$form->setFieldAttribute('producer_id', 'required', 'required');
$form->setFieldAttribute('producer_id', 'class', $form->getFieldAttribute('producer_id', 'class') . ' required');
}
if ($params->get('fed_producer_restrict', 0) == '1') {
$form->setFieldAttribute('producer_id', 'validate', 'djcproducer');
if (!empty($data->created_by) && $data->created_by > 0) {
$form->setFieldAttribute('producer_id', 'validate_user', $data->created_by);
}
}
}
if ($params->get('fed_price', '0') == '0') {
$form->removeField('price');
$form->removeField('special_price');
} else {
if ($params->get('fed_price', '0') == '2') {
$form->setFieldAttribute('price', 'required', 'required');
$form->setFieldAttribute('price', 'class', $form->getFieldAttribute('price', 'class') . ' required');
}
}
if ($params->get('fed_featured', '0') == '0') {
$form->removeField('featured');
} else {
if ($params->get('fed_featured', '0') == '2') {
$form->setFieldAttribute('featured', 'required', 'required');
$form->setFieldAttribute('featured', 'class', $form->getFieldAttribute('featured', 'class') . ' required');
}
}
if ($params->get('fed_group', '0') == '0') {
$form->removeField('group_id');
} else {
if ($params->get('fed_group', '0') == '2') {
$form->setFieldAttribute('group_id', 'required', 'true');
//$form->setFieldAttribute('group_id', 'class', $form->getFieldAttribute('group_id', 'class').' required');
}
}
if ($params->get('fed_meta', '0') == '0') {
$form->removeField('metatitle');
$form->removeField('metakey');
$form->removeField('metadesc');
}
if ($params->get('fed_intro_description_editor', null)) {
$form->setFieldAttribute('intro_desc', 'editor', $params->get('fed_intro_description_editor'));
}
if ($params->get('fed_intro_description', '0') == '0') {
$form->removeField('intro_desc');
} else {
if ($params->get('fed_intro_description', '0') == '2') {
$form->setFieldAttribute('intro_desc', 'required', 'required');
$form->setFieldAttribute('intro_desc', 'class', $form->getFieldAttribute('intro_desc', 'class') . ' required');
}
}
if ($params->get('fed_description_editor', null)) {
$form->setFieldAttribute('description', 'editor', $params->get('fed_description_editor'));
}
if ($params->get('fed_description', '0') == '0') {
$form->removeField('description');
} else {
if ($params->get('fed_description', '0') == '2') {
$form->setFieldAttribute('description', 'required', 'required');
$form->setFieldAttribute('description', 'class', $form->getFieldAttribute('description', 'class') . ' required');
}
}
$default_state = $params->get('fed_default_state', '0');
$form->setFieldAttribute('published', 'default', $default_state);
$is_owner = empty($data->created_by) && !empty($data) || isset($data->created_by) && (int) JFactory::getUser()->id === (int) $data->created_by ? true : false;
if (!(JFactory::getUser()->authorise('core.edit.state', 'com_djcatalog2') || JFactory::getUser()->authorise('core.edit.state.own', 'com_djcatalog2') && $is_owner)) {
if (isset($data->published)) {
$form->removeField('published');
}
//.........这里部分代码省略.........
示例14: onContentPrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
{
$formName = $form->getName();
// var_dump($formName);
if ($formName == 'com_users.reset_request' || $formName == 'com_users.remind' || $formName == 'com_contact.contact') {
return 1;
}
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
JForm::addFormPath(JPATH_PLUGIN_HPUSER . DS . 'forms');
$form->loadFile('hpuser', false);
$user = JFactory::getUser();
$userType = JRequest::getInt('type', -1);
if (is_object($data) && isset($data->user_type)) {
$userType = $data->user_type;
}
$form->setValue('user_type', '', $userType);
if (@$data->id > 0) {
if ($userType == 1) {
$form->loadFile('business_user', false);
} else {
$form->loadFile('normal_user', false);
}
} elseif (!$user->get('isRoot')) {
$form->loadFile('business_user', false);
$form->loadFile('normal_user', false);
}
//If not at new user, don't editable user_type field
if ($formName != 'com_users.registration' && @$data->id != 0) {
$form->setFieldAttribute('user_type', 'readonly', 'true');
$form->setFieldAttribute('username', 'readonly', 'true');
$form->setFieldAttribute('email1', 'readonly', 'true');
$form->removeField("email2");
/*if($user->get('isRoot')) {
$form->setFieldAttribute('user_type', 'readonly', 'true');
} else {
$form->setFieldAttribute('user_type', 'type', 'hidden');
}*/
} else {
$form->removeField("business_logo", "business_profile");
$form->removeField("business_banner", "business_profile");
}
return true;
}
示例15: onRoomTypePrepareForm
/**
* @param JForm $form The form to be altered.
* @param array $data The associated data for the form.
*
* @return boolean
* @since 1.6
*/
public function onRoomTypePrepareForm($form, $data)
{
// Load solidres plugin language
$lang = JFactory::getLanguage();
$lang->load('plg_extension_solidres', JPATH_ADMINISTRATOR);
if (!$form instanceof JForm) {
$this->_subject->setError('JERROR_NOT_A_FORM');
return false;
}
// Check we are manipulating a valid form.
if (!in_array($form->getName(), array('com_solidres.roomtype'))) {
return true;
}
// Add the registration fields to the form.
JForm::addFormPath(__DIR__ . '/fields');
$form->loadFile('roomtype', false);
// Toggle whether the checkin time field is required.
if ($this->params->get('param_roomtype_room_facilities', 1) > 0) {
$form->setFieldAttribute('room_facilities', 'required', $this->params->get('param_roomtype_room_facilities') == 2, 'roomtype_custom_fields');
} else {
$form->removeField('room_facilities', 'roomtype_custom_fields');
}
// Toggle whether the checkout time field is required.
if ($this->params->get('param_roomtype_room_size', 1) > 0) {
$form->setFieldAttribute('room_size', 'required', $this->params->get('param_roomtype_room_size') == 2, 'roomtype_custom_fields');
} else {
$form->removeField('room_size', 'roomtype_custom_fields');
}
// Toggle whether the cancellation prepayment field is required.
if ($this->params->get('param_roomtype_bed_size', 1) > 0) {
$form->setFieldAttribute('bed_size', 'required', $this->params->get('param_roomtype_bed_size') == 2, 'roomtype_custom_fields');
} else {
$form->removeField('bed_size', 'roomtype_custom_fields');
}
return true;
}