我开始使用zend框架并尝试提交表单我收到此错误消息: 致命错误:在第85行的/usr/local/ZendFramework/library/Zend/Xml/Security.php中调用未定义的函数libxml_disable_entity_loader()
有人可以帮助我,我提前感谢你。 :)
Controller.php这样
public function addAction()
{
$this->view->title = "Agregar album";
$this->view->headTitle($this->view->title);
$form = new Application_Form_Album ();
$form->submit->setLabel('Agregar Album');
$this->view->form = $form;
if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData))
{
$artista_id = $form->getValue('artista_id');
$nombre = $form->getValue('nombre');
$fecha = $form->getValue('fecha');
$descripcion = $form->getValue('descripcion');
$fecha = $this->fechaMysql($fecha);
$albums = new Application_Model_DbTable_Album ();
$albums->agregar($artista_id, $nombre, $fecha, $descripcion);
$this->_helper->redirector('index');
}
else
{
$form->populate($formData);
}
}
}
form.php的
<?php
class Application_Form_Album extends Zend_Form
{
public function init()
{
$this->setName('albums');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$nombre = new Zend_Form_Element_Text('nombre');
$nombre->setLabel('Nombre del album:')->setRequired(true)->
addFilter('StripTags')->addFilter('StringTrim')->
addValidator('NotEmpty');
$artista = new Zend_Form_Element_Select('artista_id');
$artista->setLabel('Seleccione artista:')->setRequired(true);
$table = new Application_Model_DbTable_Artista();
foreach ($table->listar() as $c)
{
$artista->addMultiOption($c->id, $c->nombre);
}
$descripcion = new Zend_Form_Element_Text('descripcion');
$descripcion->setLabel('Descripcion:')->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
$fecha = new Zend_Form_Element_Text('fecha');
$fecha->setLabel('Fecha lanzamiento:')->setRequired(true)->addFilter('StripTags')->
addFilter('StringTrim')->addValidator('NotEmpty');
$valiDate = new Zend_Validate_Date();
$valiDate->setFormat('dd-mm-YYYY');
$fecha->addValidator($valiDate);
$fecha->setValue(date("d-m-Y"));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
$this->addElements(array($id, $nombre,
$artista, $descripcion, $fecha, $submit));
}
}
View.phtml
<div class="formContainer">
<?php echo $this->form ?>
</div>