Je suis un débutant et j'ai suivi le tutoriel sur le site Web de zend framework pour créer une application web simple à partir d'un squelette. J'essaye d'ajouter d'autres éléments à la forme proposée par le tutoriel, en particulier un capctha 'image', mais, quand j'essaye de le rendre dans la vue appropriée, j'obtiens cette erreur fatale:Zend Captcha problèmes
Erreur fatale: Appel à la méthode non définie Zend \ Form \ Element :: getCaptcha() dans C: \ xampp \ htdocs \ nouveau \ fournisseur \ zendframework \ zendframework \ bibliothèque \ Zend \ Form \ View \ Helper \ FormCaptcha.php sur la ligne 45.
C'est le code lié à la classe albumform:
<?php
namespace Album\Form;
use Zend\Form\Element;
use Zend\Form\Form;
use Zend\Captcha\Image;
use Zend\Captcha\AdapterInterface;
class AlbumForm extends Form
{
protected $captcha;
public function __construct($name = null)
{
// we want to ignore the name passed
parent::__construct('album');
$this->captcha = new Image(array(
'expiration' => '300',
'wordlen' => '7',
'font' => 'public/fonts/glyphicons-halflings-regular.tff',
'fontSize' => '20',
'imgDir' => 'public/captcha',
'imgUrl' => '/captcha'
));
$this->add(array(
'name' => 'id',
'type' => 'Hidden',
));
$this->add(array(
'name' => 'title',
'type' => 'Text',
'options' => array(
'label' => 'Title',
),
'attributes' => array(
'value' => 'Scrivi il titolo',
'class' => 'prova',
),
));
$this->add(array(
'name' => 'artist',
'type' => 'Text',
'options' => array(
'label' => 'Artist',
),
));
$this->add(array(
'name' => 'captcha',
'attributes' => array(
'type' => 'Captcha'
),
'options' => array(
'label' => 'Please verify you are human.',
'captcha' => $this->captcha
)
));
$this->add(array(
'name' => 'submit',
'type' => 'Submit',
'attributes' => array(
'value' => 'Go',
'id' => 'submitbutton',
),
));
}
}
Voici le code dans la vue:
<?php
$form->setAttribute('action', $this->url('album', array('action' => 'add')));
$form->prepare();
echo $this->form()->openTag($form) . "\n";
echo $this->formHidden($form->get('id')) . "\n";
echo $this->formLabel($form->get('title')) . "\n";
?>
<br/>
<?php
echo $this->formInput($form->get('title')) . "\n";
?>
<br/><br/>
<?php
echo $this->formLabel($form->get('artist')) . "\n";
?>
<br/>
<?php
echo $this->formInput($form->get('artist')) . "\n";
?>
<br/><br/>
<?php
echo $this->formCaptcha($form->get('captcha')) . "\n";
echo $this->formSubmit($form->get('submit')) . "\n";
echo $this->form()->closeTag() . "\n";
?>
Pourriez-vous m'aider s'il vous plaît? Que manque-t-il?
Merci!
Vous avez raison, en même temps, je compris que je l'ai écrit glyphicons-halfelins-regular.tff au lieu de glyphicons-halfelins-regular.ttf. Maintenant, cela fonctionne parfaitement; Merci beaucoup! – Mitch85