这是我的表单,看起来没问题,所以这不应该是个问题,我还删除了enctype以确保它不是原因。
<form action="<?php echo JRoute::_('index.php?option=com_woo&task=hello.create'); ?>" enctype="multipart/form-data" method="post">
<p>
Project Name :
<input style="width:30%;" name="name" id="name"/>
<input style="display:none;" id="user_id" name="user_id" value="<?php echo $user->id;?>"/>
<input style="display:none;" id="county" name="county"/>
<input style="display:none;" id="state" name="state" />
</p>
<button type="submit" class="btn-green" id="select_county">Create Project</button>
</form>
控制器内部Hello
public function create()
{
$jinput = JFactory::getApplication()->input;
$foo = $jinput->get('state', '', 'filter');
print_r($foo);
die;
}
返回"NULL"
有什么想法吗?
state
字段已设置为display:none
。因此,每当表单提交时,它会将空输入发送到state
,这就是为什么您收到null
而不是值的原因。 - Toretto