gpt4 book ai didi

zend-framework - Zend 表单文本值保持为空

转载 作者:行者123 更新时间:2023-12-04 06:50:26 25 4
gpt4 key购买 nike

我创建了一个简单的上传表单,但在提交数据时遇到了一些问题。

该文件已正确上传,但我的小说明字段保持为空。

这是我的表格:

class Upload_Form_Uploadvideo extends Zend_Form{
public function init()
{
$this->setName('video')
->setAction('interface/videoupload')
->setMethod('post');


#id
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');

#Textfield "Videofile"
$video = new Zend_Form_Element_File('videofile', array(
'label' => 'Videofile')
);
$video->setDestination(APPLICATION_PATH.'/upload/video/toConvert/');

#Textfield "Videofile"
$desc = new Zend_Form_Element_Text('videodescription', array(
'label' => 'Description')
);
$desc->setAttrib('value','The description is not optional!');
$desc->setAttrib('size','25');


#Submit
$submit = new Zend_Form_Element_Submit('submit', array('label' => 'Upload Video'));
$submit->setAttrib('id', 'submitbutton');


#bringing everything together
$this->addElements(array($id,$video,$desc,$submit));

}
}

Controller ,将其提供给 View :
public function videouploadAction()
{
#in production this code goes to the index()
if(!$this->getRequest()->isPost()){
return $this->_forward('index');
}
$form = $this->getForm();
$this->view->via_getpost = var_dump($this->_request->getPost());

$this->view->via_getvalues= var_dump($form->getValues());

}

现在,我 var_dump $this->_request->getPost() 和 $form->getValues()。

输出如下:
array[$this->_request->getPost()]

'id' => string '0' (length=1)
'MAX_FILE_SIZE' => string '134217728' (length=9)
'videodescription' => string 'This is a test-video' (length=20)
'submit' => string 'Upload Video' (length=12)


array [$form->getValues()]

'id' => int 0
'videofile' => string 'swipeall.avi' (length=12)
'videodescription' => null

另外,我设置了“value”-attrib,没有任何效果。当用户加载站点时,我打算在框中写一些东西。

我是 Zend 的新手,所以我想我只是在监督一些愚蠢的事情,尽管我找不到它。

更新:

我真的必须通过 $_POST-Data
$formdata = $this->getRequest()->getPost();

最佳答案


$desc->setValue('The description is not optional!');

代替
$desc->setAttrib('value','The description is not optional!');

关于zend-framework - Zend 表单文本值保持为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3201268/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com