为什么控制器不读取加载参数的 if 函数?

why the controller don't read an if function loading the parameters?

这是我在控制器中创建的函数:

public function actionCreate()
    {
        $searchModel = new AutoriSearch();
        $model = new Autori();
        $model->RIDUtente = Yii::$app->user->getId();
        $model->Accettazione='SI';

        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
        
        if ($model->load(Yii::$app->request->post()) ) {
            
        $model->modified = date( 'y-m-d' );
        $model->creator_aut = Yii::$app->user->getId();
        $model->Utenteup_autori = Yii::$app->user->getId();
        if ($model->IParte) {
            $model->CampoRicerca = $model->IParte." ".$model->IIParte." ".$model->Prefisso." ".$model->Qualificazione." ".$model->IIEnte." ".$model->Sigla;
        }
            if($model->Accettazione == "" || $model->Accettazione == 'SI' ){
                $model->RIDAutore = $model->IDAutore;
            }
        $model->save();
        return $this->redirect(['view', 'id' => $model->IDAutore]);
    }

        return $this->render('create', [
            'model' => $model,
            'dataProvider' => $dataProvider,
            'searchModel' => $searchModel,

        ]);
    }

问题是记录没有保存,系统没有在if函数中输入"if ($model->load(Yii::$app->request->post ()))”。所以这是一个问题。在其他控制器中它没有给我错误,对于这个控制器它给了我错误。这很奇怪。谁能帮我快速吗?这很重要!!!!谢谢。

这是表格:

<div class="autori-form">

    <?php $form = ActiveForm::begin([
        'action' => ['index'],
        'method' => 'get',
        'type' => ActiveForm::TYPE_HORIZONTAL,
        
    ]); ?>

    <?= $form->field($model, 'IParte', ['labelOptions'=>['style'=>'font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>'width:190px; height: 30px;'])->label('I Parte del nome') ?>

    <?= $form->field($model, 'IIParte', ['labelOptions'=>['style'=>'position: relative; top: -63px; left: 360px;font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:190px; position: relative; position: relative; top: -58px; left: 360px;'])->label('Autori:<br>II Parte del nome') ?>
    
    <?= $form->field($model, 'IIEnte', ['labelOptions'=>['style'=>'width: 100px; position: relative; top: -120px; left: 800px;font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:190px; position: relative; top: -116px; left: 800px;'])->label('Enti: Ente subordinato') ?>
<div style="position: relative; top: -120px;">
    <?= $form->field($model, 'Prefisso', ['labelOptions'=>['style'=>'font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:300px'])->label('Appellativi o altra parte del nome') ?>

    <?= $form->field($model, 'Sigla', ['labelOptions'=>['style'=>'font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:300px'])->label('Sigla dell\'ordine') ?>

    <?= $form->field($model, 'Qualificazione', ['labelOptions'=>['style'=>'font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:300px'])->label('Qualificazioni') ?>

    <?= $form->field($model, 'Fonte', ['labelOptions'=>['style'=>'font-size: 12px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:300px']) ?>

    <?= $form->field($model, 'RIDTipoAutore', ['labelOptions'=>['style'=>'font-size: 12px;']])->dropdownList(
        TipiAutore::find()
        ->select(['TipoAutore'])
        ->indexBy('IDTipoAutore')
        ->column(),
        ['prompt'=>'', 'style'=>' height: 30px; width:300px']
    )->label('Tipo Autore') ?>

    <?= $form->field($model, 'Accettazione', ['labelOptions'=>['style'=>'font-size: 12px;']])->dropdownList(
        Autori::find()
        ->select(['Accettazione'])
        ->indexBy('Accettazione')
        ->column(),
        ['style'=>' height: 30px; width:300px', 'onchange' => 'accettato(this)'] 
    )->label('Accettazione') ?>   

    

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

    
    <?= $form->field($model, 'RIDUtente')->hiddenInput(['value'=> Yii::$app->user->identity->id])->label(false) ?>

     <?= $form->field($model, 'RIDAutore', ['labelOptions'=>['style'=>'font-size: 12px; position: relative; top: -28px;']])->textInput(['maxlength' => true, 'style'=>' height: 30px; width:300px; position: relative; top: -28px;', 'disabled' => true])->label('Forma accettata') ?>
    </div>
     <a name="button" id="btnMostra" style="position: relative; top: -199px; left: 540px; cursor: pointer;">Clicca per ricercare la forma accettata</a> 

    <script>
        function accettato(select) {
           console.log(select,$(select));
           $("#autori-ridautore").prop("disabled", $(select).val()!="NO"); 
        }
    </script>

    
    <?= Html::hiddenInput( 'modified', strtotime("now") ); ?>

    <div class="form-group" style="position: relative; top: -170px; left: 860px; width: 200px;">
        <?= Html::submitButton(Yii::t('app', 'Salva'), ['class' => 'btn btn-success']) ?>
        &nbsp;&nbsp;&nbsp;&nbsp;<?= Html::a('Annulla', ['autori/index'], ['class'=>'btn btn-info']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>

Autori.php的规则:

public function rules()
    {
        return [
            [['RIDUtente', 'modified', 'RIDTipoAutore'], 'required'],
            [['RIDUtente', 'RIDAutore', 'RIDTipoAutore', 'creator_aut'], 'integer'],
            [['IParte', 'IIEnte'], 'string', 'max' => 100],
            [['IIParte', 'Qualificazione'], 'string', 'max' => 50],
            [['Prefisso'], 'string', 'max' => 30],
            [['Sigla'], 'string', 'max' => 10],
            [['Accettazione'], 'string', 'max' => 2],
            [['CampoRicerca'], 'string', 'max' => 400],
            [['Fonte'], 'string', 'max' => 3200],
            [['modified'], 'string', 'max' => 8],
        ];
    }

AutoriSearch 模型规则:

public函数规则()

{
    return [
        [['IDAutore', 'RIDUtente', 'RIDAutore', 'RIDTipoAutore', 'creator_aut'], 'integer'],
        [['autoreMix', 'IParte', 'IIParte', 'Prefisso', 'Qualificazione',
        'IIEnte', 'Sigla', 'Accettazione', 'CampoRicerca',
        'Fonte', 'modified'], 'safe'],
    ];
}

您的表单方法是 get,但您通过 post 获取数据,这是不兼容的

 'method' => 'get',

 $model->load(Yii::$app->request->post()