我有一个编辑视图,需要通过 Joomla 2.5 组件中的表单传递隐藏值。我将在哪里添加此表单值?
这是我的尝试(不起作用):
在../admin/models/forms/componentview.xml
文件中,我添加了以下字段:
<field
name="variableToPassBackToMainView"
type="hidden"
value="1"
/>
我的想法是,通过将这个隐藏字段添加到模型表单中,当它被保存时,它variableToPassBackToMainView
就会被新视图拾取。该视图具有以下变量定义来检索值:
$variableToPassBackToMainView = $_REQUEST["variableToPassBackToMainView"];
更新信息:
Joomla 2.5 组件
这里是edit.php
<?php
defined('_JEXEC') or die('Restricted access');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
$params = $this->form->getFieldsets('params');
?>
<form action="<?php echo JRoute::_('index.php?option=com_mycomponent&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="mycomponent-form" class="form-validate">
<div class="width-60 fltlft">
<fieldset class="adminform">
<legend><?php echo JText::_( 'COM_MYCOMPONENT_DETAILS' ); ?></legend>
<ul class="adminformlist">
<?php foreach($this->form->getFieldset('componenttitledetails') as $field): ?>
<li><?php echo $field->label;echo $field->input;?></li>
<?php endforeach; ?>
</ul>
</div>
<div class="width-40 fltrt">
<?php echo JHtml::_('sliders.start', 'mycomponent-slider'); ?>
<?php foreach ($params as $name => $fieldset): ?>
<?php echo JHtml::_('sliders.panel', JText::_($fieldset->label), $name.'-params');?>
<?php if (isset($fieldset->description) && trim($fieldset->description)): ?>
<p class="tip"><?php echo $this->escape(JText::_($fieldset->description));?></p>
<?php endif;?>
<fieldset class="panelform" >
<ul class="adminformlist">
<?php foreach ($this->form->getFieldset($name) as $field) : ?>
<li><?php echo $field->label; ?><?php echo $field->input; ?></li>
<?php endforeach; ?>
</ul>
</fieldset>
<?php endforeach; ?>
<?php echo JHtml::_('sliders.end'); ?>
</div>
<div>
<input type="hidden" name="task" value="componentview.edit" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>