2

When working with Yii 2.0 I keep up facing this problem:

Fatal error: Uncaught Error: Class 'yii\widgets\ActiveForm' not found"

I have checked the the widgets and ActiveForm is present. I tried also with yii\bootstrap\ActiveForm but the same error keep ocuring.

<?php $form = ActiveForm::begin(); ?>

<?= $form->field($model, 'ID_ENSEIGNANT') ?>
<?= $form->field($model, 'DATENAISSANCE') ?>
<?= $form->field($model, 'MATRICULE') ?>
<?= $form->field($model, 'NOM') ?>
<?= $form->field($model, 'PRENOM') ?>
<?= $form->field($model, 'DISCIPLINE') ?>
<?= $form->field($model, 'FONCTION') ?>
<?= $form->field($model, 'SEX') ?>
<?= $form->field($model, 'TEL') ?>
<?= $form->field($model, 'EMAIL') ?>
<?= $form->field($model, 'ADRESSE') ?>
<?= $form->field($model, 'STATUT') ?>

<div class="form-group">
    <?= Html::submitButton('Submit', ['class' => 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
rob006
  • 21,383
  • 5
  • 53
  • 74
  • Have you got this class autoloaded? Have you got the same problem with that class in other places or is it only in that view? – Bizley Jul 31 '19 at 06:42
  • yeah I got it uploaded (use yii\widgets\ActiveForm;) I've got the same prob in all views – Me Developing Jul 31 '19 at 08:04
  • 1
    Sounds like you don't use Composer, is that correct? – Bizley Jul 31 '19 at 08:16
  • wen using `namespace` along with the function call you should not forget the starting `\ `, either add `use yii\bootstrap\ActiveForm` on top of your view or change `` to `` – Muhammad Omer Aslam Jul 31 '19 at 20:07
  • 1
    I did all of that but nothing. Anyway its sound like I didnt install composer correctly beacause I started over and its working now – Me Developing Aug 01 '19 at 09:44

1 Answers1

0

You need to used activeform before used in page.

use yii\widgets\ActiveForm;
Ravi Thanki
  • 251
  • 2
  • 14