本文整理汇总了PHP中JForm::setValue方法的典型用法代码示例。如果您正苦于以下问题:PHP JForm::setValue方法的具体用法?PHP JForm::setValue怎么用?PHP JForm::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JForm
的用法示例。
在下文中一共展示了JForm::setValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$section = $this->state->get('category.section') ? $this->state->get('category.section') . '.' : '';
$this->canDo = JHelperContent::getActions($this->state->get('category.component'), $section . 'category', $this->item->id);
$this->assoc = $this->get('Assoc');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
// Check for tag type
$this->checkTags = JHelperTags::getTypes('objectList', array($this->state->get('category.extension') . '.category'), true);
JFactory::getApplication()->input->set('hidemainmenu', true);
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例2: display
/**
* Display the view.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*/
public function display($tpl = null)
{
// Initialise variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例3: display
/**
* Display the view
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return void
*
* @since 1.6
*/
public function display($tpl = null)
{
$user = JFactory::getUser();
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->modules = $this->get('Modules');
$this->levels = $this->get('ViewLevels');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_menus', 'menu', (int) $this->state->get('item.menutypeid'));
// Check if we're allowed to edit this item
// No need to check for create, because then the moduletype select is empty
if (!empty($this->item->id) && !$this->canDo->get('core.edit')) {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
parent::display($tpl);
$this->addToolbar();
}
示例4: display
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->form->setValue('password', null);
$this->form->setValue('password2', null);
$this->addToolbar();
return parent::display($tpl);
}
示例5: render
/**
* Render HTML Markup for administrator UI
*
* @return string
*/
public function render()
{
$adminFormXml = $this->_generateFormXML();
// Create form instance
$this->adminForm = new JForm('template-setting');
$this->adminForm->addFieldPath(JSN_PATH_TPLFRAMEWORK . '/libraries/joomlashine/form/fields');
$this->adminForm->load($adminFormXml->asXML());
$params = $this->helper->loadParams($this->data->params, $this->data->template);
// Bind value of parameters to form
foreach ($params as $key => $value) {
$this->adminForm->setValue($key, 'jsn', $value);
}
// Get Joomla application object
$app = JFactory::getApplication();
// Store current compression parameters
$app->setUserState('jsn.template.maxCompressionSize', $params['maxCompressionSize']);
$app->setUserState('jsn.template.cacheDirectory', $params['cacheDirectory']);
// Start rendering
ob_start();
include JSN_PATH_TPLFRAMEWORK_LIBRARIES . '/template/tmpl/default.php';
$body = ob_get_clean();
// Detect method to use for getting and setting response body
if (version_compare(JVERSION, '3.2.0', 'ge')) {
$get = array($app, 'getBody');
$set = array($app, 'setBody');
} else {
$get = array('JResponse', 'getBody');
$set = array('JResponse', 'setBody');
}
// Parse current response body
list($head, $tmp) = preg_split('/<form[^>]+name="adminForm"[^>]*>/', call_user_func($get), 2);
list($tmp, $foot) = explode('</form>', $tmp, 2);
// Replace current response body
call_user_func($set, $head . $body . $foot);
}
示例6: display
/**
* Document edit page.
*
* @param string $tpl used template name
* @return void
*/
public function display($tpl = null)
{
$mainframe = JFactory::getApplication();
/* @var $mainframe JAdministrator */
$config = JoomDOCConfig::getInstance();
/* @var $config JoomDOCConfig */
$model = $this->getModel();
/* @var $model JoomDOCModelDocument */
$this->form = $model->getForm();
$this->document = $model->getItem();
$this->state = $model->getState();
$this->access = new JoomDOCAccessHelper($this->document);
if (!isset($this->document->id) || empty($this->document->id)) {
$this->form->setValue('path', null, $mainframe->getUserState('path'));
$this->form->setValue('title', null, JFile::getName($mainframe->getUserState('path')));
}
$this->addToolbar();
parent::display($tpl);
}
示例7: date
/**
* Display date form field. If field value equal database null date reset to empty string.
*
* @param string $field form field name
* @return string field form html
*/
public function date($field)
{
static $nullDate;
if (empty($nullDate)) {
$db = JFactory::getDbo();
/* @var $db JDatabaseMySQL */
$nullDate = $db->getNullDate();
}
if ($this->form->getValue($field) == $nullDate) {
$this->form->setValue($field, null, '');
}
return $this->form->getInput($field);
}
示例8: display
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.6
*/
public function display($tpl = null)
{
if ($this->getLayout() == 'pagebreak') {
// TODO: This is really dogy - should change this one day.
$eName = JFactory::getApplication()->input->getCmd('e_name');
$eName = preg_replace('#[^A-Z0-9\\-\\_\\[\\]]#i', '', $eName);
$this->document->setTitle(JText::_('COM_CONTENT_PAGEBREAK_DOC_TITLE'));
$this->eName =& $eName;
return parent::display($tpl);
}
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$this->canDo = JHelperContent::getActions('com_content', 'article', $this->item->id);
// Check for errors.
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
if ($this->getLayout() == 'modal') {
// If we are forcing a language in modal (used for associations).
if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd')) {
// Set the language field to the forcedLanguage and disable changing it.
$this->form->setValue('language', null, $forcedLanguage);
$this->form->setFieldAttribute('language', 'readonly', 'true');
// Only allow to select categories with All language or with the forced language.
$this->form->setFieldAttribute('catid', 'language', '*,' . $forcedLanguage);
// Only allow to select tags with All language or with the forced language.
$this->form->setFieldAttribute('tags', 'language', '*,' . $forcedLanguage);
}
} elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled() && count($this->item->associations) > 0) {
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
$this->addToolbar();
return parent::display($tpl);
}
示例9: displayTask
/**
* Default view function
*
* @return void
*/
public function displayTask()
{
// Get scope
$this->view->scope = Request::getWord('scope', 'Hub');
$this->view->scope_id = Request::getInt('scope_id', 0);
// Get permissions
$access = new \JForm('permissions');
$access->loadFile(dirname(dirname(__DIR__)) . DS . 'models' . DS . 'forms' . DS . 'permissions.xml');
// Bind existing rules if applicable
$asset = new \JTableAsset($this->database);
$name = 'com_time.' . strtolower($this->view->scope) . '.' . $this->view->scope_id;
$asset->loadByName($name);
if ($asset->get('id')) {
$access->setValue('asset_id', null, $asset->get('id'));
}
$this->view->permissions = $access->getField(strtolower($this->view->scope));
// Display
$this->view->display();
}
示例10: preprocessForm
//.........这里部分代码省略.........
$fieldset->addAttribute('name', $section);
$fieldset->addAttribute('label', $section);
continue;
} elseif (!$header && preg_match('/^;(.*)$/', $line, $matches)) {
$key = $matches[1];
$field = $fieldset->addChild('field');
$field->addAttribute('label', $key);
$field->addAttribute('type', 'spacer');
$field->addAttribute('class', 'text');
continue;
} elseif (preg_match('/^([A-Z][A-Z0-9_\\-\\.]*)\\s*=/', $line, $matches)) {
$header = false;
$key = $matches[1];
$field = $fieldset->addChild('field');
$string = $refsections['keys'][$key];
$translated = isset($sections['keys'][$key]);
$modified = $translated && $sections['keys'][$key] != $refsections['keys'][$key];
$status = $modified ? 'translated' : ($translated ? 'unchanged' : 'untranslated');
$default = $translated ? $sections['keys'][$key] : '';
$label = '<b>' . $key . '</b><br />' . htmlspecialchars($string, ENT_COMPAT, 'UTF-8');
$field->addAttribute('status', $status);
$field->addAttribute('description', $string);
if ($default) {
$field->addAttribute('default', $default);
} else {
$field->addAttribute('default', $string);
}
$field->addAttribute('label', $label);
$field->addAttribute('name', $key);
$field->addAttribute('type', 'key');
$field->addAttribute('filter', 'raw');
continue;
} elseif (!preg_match('/^(|(\\[[^\\]]*\\])|([A-Z][A-Z0-9_\\-\\.]*\\s*=(\\s*(("[^"]*")|(_QQ_)))+))\\s*(;.*)?$/', $line)) {
$this->item->error[] = $lineNumber;
}
}
$stream->close();
$newstrings = false;
if (!empty($sections['keys'])) {
foreach ($sections['keys'] as $key => $string) {
if (!isset($refsections['keys'][$key])) {
if (!$newstrings) {
$newstrings = true;
$form->load($addform, false);
$section = 'New Strings';
$addform = new JXMLElement('<form />');
$group = $addform->addChild('fields');
$group->addAttribute('name', 'strings');
$fieldset = $group->addChild('fieldset');
$fieldset->addAttribute('name', $section);
$fieldset->addAttribute('label', $section);
}
$field = $fieldset->addChild('field');
$status = 'extra';
$default = $string;
$label = '<b>' . $key . '</b>';
$field->addAttribute('status', $status);
$field->addAttribute('description', $string);
if ($default) {
$field->addAttribute('default', $default);
} else {
$field->addAttribute('default', $string);
}
$field->addAttribute('label', $label);
$field->addAttribute('name', $key);
$field->addAttribute('type', 'key');
$field->addAttribute('filter', 'raw');
}
}
}
}
$form->load($addform, false);
}
// Check the session for previously entered form data.
$data = $app->getUserState('com_localise.edit.translation.data', array());
// Bind the form data if present.
if (!empty($data)) {
$form->bind($data);
}
if ($origin != '_thirdparty' && $origin != '_override') {
$packages = LocaliseHelper::getPackages();
$package = $packages[$origin];
if (!empty($package->author)) {
$form->setValue('author', $package->author);
$form->setFieldAttribute('author', 'readonly', 'true');
}
if (!empty($package->copyright)) {
$form->setValue('maincopyright', $package->copyright);
$form->setFieldAttribute('maincopyright', 'readonly', 'true');
}
if (!empty($package->license)) {
$form->setValue('license', $package->license);
$form->setFieldAttribute('license', 'readonly', 'true');
}
}
if ($form->getValue('description') == '' && array_key_exists($tag, $languages[$client])) {
$form->setValue('description', $filename . ' ' . $languages[$client][$tag]['name']);
}
return $form;
}
示例11: 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;
}
示例12: 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
*
* @since 1.6
*/
public function onContentPrepareForm($form, $data)
{
$app = JFactory::getApplication();
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;
}
// Add the registration fields to the form.
JForm::addFormPath(__DIR__ . '/sibdiets');
$form->loadFile('sibdiet', false);
if ($name == 'com_users.registration') {
$form->setFieldAttribute('id', 'type', 'hidden', 'sibdiet');
if ($agent = $app->input->get('agent', 0, 'INT')) {
$form->setValue('created_by', 'sibdiet', $agent);
}
}
// Permissions field will show just in joomla backend and only for super admins.
if (!JFactory::getUser()->get('isRoot') || !$app->isAdmin()) {
// We only want the Permissions in the backend just for super user
$form->removeField('permissions', 'sibdiet');
// We only want the Created by in the backend just for super user
$form->setFieldAttribute('created_by', 'type', 'hidden', 'sibdiet');
}
// Fix File Number
if (!empty($data->sibdiet['id'])) {
$data->sibdiet['id'] += 200000;
}
return true;
}
示例13: display
function display($tpl = null)
{
global $mainframe;
//initialise variables
$document = JFactory::getDocument();
$db = JFactory::getDBO();
$me = JFactory::getUser();
$cid = JRequest::getVar('cid', array(0), '', 'array');
JArrayHelper::toInteger($cid, array(0));
$edit = JRequest::getVar('edit', true);
if (!$cid) {
$edit = false;
}
if (FLEXI_J16GE) {
$form = $this->get('Form');
$form->setValue('password', null);
$form->setValue('password2', null);
}
$form_folder = FLEXI_J16GE ? 'forms' . DS : '';
JHTML::_('behavior.tooltip');
//add css to document
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
if (FLEXI_J30GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
} else {
if (FLEXI_J16GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
} else {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
}
}
//add js function to overload the joomla submitform
$document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/admin.js');
$document->addScript(JURI::root() . 'components/com_flexicontent/assets/js/validate.js');
// load language file for com_users component
JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, 'en-GB', true);
JFactory::getLanguage()->load('com_users', JPATH_ADMINISTRATOR, null, true);
//create the toolbar
if ($edit) {
JToolBarHelper::title(JText::_('FLEXI_EDIT_AUTHOR'), 'authoredit');
} else {
JToolBarHelper::title(JText::_('FLEXI_ADD_AUTHOR'), 'authoradd');
}
$ctrl = FLEXI_J16GE ? 'users.' : '';
JToolBarHelper::apply($ctrl . 'apply');
JToolBarHelper::save($ctrl . 'save');
JToolBarHelper::custom($ctrl . 'saveandnew', 'savenew.png', 'savenew.png', 'FLEXI_SAVE_AND_NEW', false);
JToolBarHelper::cancel($ctrl . 'cancel');
JToolBarHelper::help('screen.users.edit');
$user = $edit ? JUser::getInstance($cid[0]) : JUser::getInstance();
$myuser = JFactory::getUser();
$acl = JFactory::getACL();
// Check for post data in the event that we are returning
// from a unsuccessful attempt to save data
$post = JRequest::get('post');
if ($post) {
$user->bind($post);
}
if ($user->get('id')) {
$query = 'SELECT *' . ' FROM #__contact_details' . ' WHERE user_id = ' . (int) $cid[0];
$db->setQuery($query);
$contact = $db->loadObjectList();
} else {
$contact = NULL;
// Get the default group id for a new user
$config = JComponentHelper::getParams('com_users');
$newGrp = $config->get('new_usertype');
if (!FLEXI_J16GE) {
$user->set('gid', $acl->get_group_id($newGrp, null, 'ARO'));
} else {
$user->set('gid', $newGrp);
}
}
// **************************************************
// Include needed files and add needed js / css files
// **************************************************
// Load pane behavior
jimport('joomla.html.pane');
// Load tooltips
FLEXI_J30GE ? JHtml::_('behavior.framework', true) : JHTML::_('behavior.mootools');
JHTML::_('behavior.tooltip');
// Add css to document
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/flexicontentbackend.css');
if (FLEXI_J30GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j3x.css');
} else {
if (FLEXI_J16GE) {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j25.css');
} else {
$document->addStyleSheet(JURI::base() . 'components/com_flexicontent/assets/css/j15.css');
}
}
// Add js function to overload the joomla submitform
$document->addScript('components/com_flexicontent/assets/js/admin.js');
$document->addScript('components/com_flexicontent/assets/js/validate.js');
// ********************
// Initialise variables
// ********************
$cparams = JComponentHelper::getParams('com_flexicontent');
if (!FLEXI_J16GE) {
//.........这里部分代码省略.........
示例14: getQuickaddForm
/**
* getQuickaddForm
*/
public static function getQuickaddForm($id, $path, $extension = null)
{
$content = '';
//JForm::addFormPath(AKHelper::_('path.get', null, $extension).'/models/forms');
//JForm::addFieldPath(AKHelper::_('path.get', null, $extension).'/models/fields');
try {
$form = new JForm($id . '.quickaddform', array('control' => $id));
$form->loadFile(JPATH_ROOT . '/' . $path);
} catch (Exception $e) {
Jerror::raiseWarning(404, $e->getMessage());
return false;
}
// Set Category Extension
if ($extension) {
$form->setValue('extension', null, $extension);
}
$fieldset = $form->getFieldset('quickadd');
foreach ($fieldset as $field) {
$content .= "<div class=\"control-group\" id=\"jform_basic_alias-wrap\">\n <div class=\"control-label\">\n {$field->label}\n </div>\n <div class=\"controls\">\n {$field->input}\n </div>\n </div>";
}
if (JVERSION < 3) {
$content = "<fieldset class=\"adminform form-horizontal\">{$content}</fieldset>";
}
return $content;
}
示例15: setValue
/**
* set value into forfield and $this->extraValues
* note: JForm::setValue($fieldname, $value) check the forfield options list,
* and not save value if it is not valid. This function save value into
* $this->extraValues ohne check.
* @result void
* @param string $fieldname
* @param string $value
*/
public function setValue($fieldName, $group = null, $value)
{
$this->extraValues[$fieldName] = $value;
parent::setValue($fieldName, $group, $value);
}