yii 2 getActiveValidators() on null

I used gii to create my crud, and I have been handling the data, I have relationated 2 tables, and at the time of modifying I have not had problems, the problem appears when I want to create data, since I get the error getActiveValidators () On null, I leave the code I use to display data from the related tables, since I modify the form ‘_form’ for that purpose. to update:


<div class="subcategoria-form">


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

    <!--This is the code of the related table, subcategory-> category-> name-->

    <?= $form->field($model->categoria, 'nombre')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'nombre')->textInput(['maxlength' => true]) ?>




   <!-- <?= $form->field($model, 'categoria_id')->textInput() ?>


    <?= $form->field($model, 'nivel')->textInput() ?>


    <?= $form->field($model, 'padre_id')->textInput() ?>


    <?= $form->field($model, 'updated_at')->textInput() ?>


    <?= $form->field($model, 'created_at')->textInput(['maxlength' => true]) ?>-->


    <div class="form-group">

        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Crear') : Yii::t('app', 'Modificar'), ['class' =>       $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>

    </div>

no problems,But the "create" generates the problem, What could it be?

Is "$model->categoria" null?