我正在使用 joomla 并且我已经开始开发一个网络应用程序,我想从表单字段中获取值。通常我使用 $_POST 但此页面不起作用。
这是我的default.php >>>
<?php
defined('_JEXEC') or die;
JHtml::_('behavior.keepalive');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.formvalidation');
?>
<div class="item" <?php echo $this->pageclass_sfx?>">
<?php if ($this->params->get('show_page_heading')) : ?>
<h1><?php echo $this->escape($this->params->get('page_heading')); ?></h1>
<?php endif; ?>
<form id="add-item" action="<?php echo JRoute::_('index.php?option=com_stationery&task=item.save'); ?>" method="post" class="form-validate" enctype="multipart/form-data">
<?php foreach ($this->form->getFieldsets() as $fieldset): // Iterate through the form fieldsets and display each one.?>
<?php $fields = $this->form->getFieldset($fieldset->name);?>
<?php if (count($fields)):?>
<fieldset>
<?php if (isset($fieldset->label)):// If the fieldset has a label set, display it as the legend.
?>
<legend><?php echo JText::_($fieldset->label);?></legend>
<?php endif;?>
<dl>
<?php foreach($fields as $field):// Iterate through the fields in the set and display them.?>
<?php if ($field->hidden):// If the field is hidden, just display the input.?>
<?php echo $field->input;?>
<?php else:?>
<dt>
<?php echo $field->label; // Show label for registor ?>
<?php if (!$field->required && $field->type!='Spacer'): ?>
<?php endif; ?>
</dt>
<dd><?php echo ($field->type!='Spacer') ? $field->input : " "; ?></dd>
<?php endif;?>
<?php endforeach;?>
</dl>
</fieldset>
<?php endif;?>
<?php endforeach;?>
<div>
<button name="save" type="submit" class="btn btn-success" class="validate"><?php echo JText::_('Save');?></button>
<?php echo JText::_('or');?>
<a class="btn btn-danger" href="<?php echo JRoute::_('/stationery/index.php/add-items');?>" title="<?php echo JText::_('JCANCEL');?>"><?php echo JText::_('JCANCEL');?></a>
<input type="hidden" name="option" value="com_stationery" />
<input type="hidden" name="task" value="item.save" />
<?php echo JHtml::_('form.token');?>
</div>
</form>
<script>
这是 field.xml 中的循环以显示每个字段。我想在那个输入框中获得价值。现在我可以访问 javascript 变量,但我不能用来保存在我的表中。我想要 php 变量($....)。我怎么才能得到它?请帮我。谢谢