Erreur Zend_Form_Element_MultiCheckbox
al-ali
-
al-ali -
al-ali -
Bonjour, voici mon code
application/forms/semestre.php
application/controllers/indexcontroller.php
</code>
et voici l'erreur qui s'affiche
application/forms/semestre.php
class Form_Semestre extends Zend_Form
{
public function __construct($options = null)
{
parent::__construct($options);
$this->setName('unionmois_semestre');
$id = new Zend_Form_Element_Hidden('codeunion1');
$namecheckbox = new Zend_Form_Element_MultiCheckbox('namecheckbox');
$namecheckbox->setUncheckedValue(0)
->setCheckedValue(1)
->setValue(1)
->setRequired(1);
$codesemestre = new Zend_Form_Element_Text('codesemestre');
$codesemestre->setLabel('codesemestre')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$Ajouter = new Zend_Form_Element_Submit('Ajouter');
$Ajouter->setAttrib('mois', 'boutonAjouter');
$this->addElements(array($id ,$namecheckbox, $codesemestre, $Ajouter));
}
}
application/controllers/indexcontroller.php
public function ajoutsemestreAction()
{
$form = new Form_Semestre();
$form->Ajouter->setLabel('namecheckbox');
$this->view->form = $form ;
if ($this->getRequest()->isPost()) {
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$codemois = $form->getValue('namecheckbox');
$codesemestre = $form->getValue('codesemestre');
//var_dump($codemois ); exit();
$semestre = new Model_DbTable_Semestre();
$semestre->ajouterUnion($codesemestre,$codemois);
$this->_redirect('/');
} else {
$form->populate($formData);
}
}
}
<?php
application/models/DbTable/semestre.php
class Model_DbTable_Semestre extends Zend_Db_Table_Abstract
{
protected $_name = 'unionmois_semestre';
public function obtenirUnion($id)
{
$id = (int)$id;
$row = $this->fetchRow('codeunion1 = ' . $id);
if (!$row) {
throw new Exception("Count not find row $id");
}
return $row->toArray();
}
public function ajouterUnion($codesemestre,$codemois)
{
$data = array(
'codesemestre' => $codesemestre,
'codemois' => $codemois,
);//var_dump($data); exit();
$this->insert($data);
}
public function modifierUnion($id, $codesemestre,$codemois)
{
$data = array(
'codesemestre' => $codesemestre,
'codemois' => $codemois,
);
$this->update($data, 'codeunion1 = '. (int)$id);
}
public function supprimerUnion($id)
{
$this->delete('codeunion1 =' . (int)$id);
}
}
semestre.phtml
<code html>
<div id="div_formCreation">
<form action="<?php echo $this->url(array('action'=>'ajoutsemestre')); ?>" method="post" id="formCreation">
<table>
<tr><td>Semestre :</td><td>
<select name="codesemestre" id="codesemestrecreation" onchange=""><option value=""></option>
<?php foreach($this->semestre1 as $semestre1) : ?>
<option value="<?php echo $this->escape($semestre1->codesemestre);?>"><?php echo $this->escape($semestre1->semestre);?></option>
<?php endforeach; ?>
</select>
</td></tr>
<tr>
<td>
<table>
<?php foreach($this->mois as $mois) : ?>
<tr>
<td><input type="checkbox" name="namecheckbox[]" value="<?php echo $this->escape($mois->codemois)?>" id="checkbox_<?php echo $this->escape($mois->codemois)?>"></td><td><?php echo $this->escape($mois->mois);?></td>
</tr>
<?php endforeach; ?>
</table>
</td>
</tr>
<tr><td><input type="submit" name="Ajouter" value="Ajouter" class=""></td></tr>
</table>
</form>
</div>
</code>
et voici l'erreur qui s'affiche
An error occurred
Application error
Exception information:
Message: Method setUncheckedValue does not exist
Stack trace:
#0 C:\wamp\www\tutoriel-zf\application\forms\semestre.php(12): Zend_Form_Element->__call('setUncheckedVal...', Array)
#1 C:\wamp\www\tutoriel-zf\application\controllers\IndexController.php(767): Form_Semestre->__construct()
#2 C:\wamp\www\tutoriel-zf\library\Zend\Controller\Action.php(516): IndexController->ajoutsemestreAction()
#3 C:\wamp\www\tutoriel-zf\library\Zend\Controller\Dispatcher\Standard.php(295): Zend_Controller_Action->dispatch('ajoutsemestreAc...')
#4 C:\wamp\www\tutoriel-zf\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#5 C:\wamp\www\tutoriel-zf\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#6 C:\wamp\www\tutoriel-zf\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#7 C:\wamp\www\tutoriel-zf\public\index.php(26): Zend_Application->run()
#8 {main}
Request Parameters:
array (
'controller' => 'index',
'action' => 'ajoutsemestre',
'module' => 'default',
'codesemestre' => '3',
'namecheckbox' =>
array (
0 => '1',
1 => '3',
2 => '5',
),
'Ajouter' => 'Ajouter',
)
A voir également:
- Erreur Zend_Form_Element_MultiCheckbox
- Erreur 0x80070643 - Accueil - Windows
- Erreur 4201 france tv ✓ - Forum Réseaux sociaux
- Erreur 4101 france tv - Forum Lecteurs et supports vidéo
- J'aime par erreur facebook notification - Forum Facebook
- Code erreur f3500-31 ✓ - Forum Bbox Bouygues
3 réponses
Salut,
D'après le message d'erreur, la classe Zend_Form_Element_MultiCheckbox ne possède pas la méthode setUncheckedValue().
Quelle version de Zend Framework utilises tu ?
Bonne journée,
D'après le message d'erreur, la classe Zend_Form_Element_MultiCheckbox ne possède pas la méthode setUncheckedValue().
Quelle version de Zend Framework utilises tu ?
Bonne journée,
Effectivement cette méthode ne semble pas exister en 1.11 : https://framework.zend.com/manual/1.11/fr/zend.form.standardElements.html#zend.form.standardElements.multiCheckbox
Ton utilisation de cette méthode semble correspondre à la version 2 du framework.
Ton utilisation de cette méthode semble correspondre à la version 2 du framework.
bonsoir j'ai essayé d'installer zend framework 2 ,j'ai suivie ce tuto sur ce lien
et apres des recherches
j'ai trouvé ceci
C:\wamp\www\zf2-tutorial\config\application.config
quand je change
file:///C:/wamp/www/tutoriel-zf/recherches/D%C3%A9marrer%20avec%20Zend%20Framework%202.htmpour installer zend framework 2 mais apres avoir suivie les instruction je retrouve cette erreur
Fatal error: Uncaught exception 'Zend\ModuleManager\Listener\Exception\RuntimeException' with message 'Could not find a valid ServiceManager for RoutePluginManager' in C:\wamp\www\zf2-tutorial\vendor\zendframework\zend-modulemanager\src\Listener\ServiceListener.php on line 202
et apres des recherches
j'ai trouvé ceci
C:\wamp\www\zf2-tutorial\config\application.config
<?php
return array(
'modules' => array (
'Application',
'Album',
),
'module_listener_options' => array(
'config_glob_paths' => array(
realpath(__DIR__) . '/autoload/{{,*.}global,{,*.}local}.php',
),
'config_cache_enabled' => false,
'module_map_cache_enabled' => true,
'config_cache_key' => 'application.config.cache',
'cache_dir' => 'data/cache',
'module_paths' => array(
'./module',
'./vendor',
),
),
'service_manager' => array(
'use_defaults' => true,
'factories' => array(
),
),
);
quand je change
'config_cache_enabled' => false mais quand je fais 'config_cache_enabled' => true l'erreur s'en va mais s'affiche le menu principal(partie Virtual host dans le tuto ) au que celui tu tuto s'affiche(partie Lister les albums)