【问题标题】:Yii2:link to related update page from different modelYii2:链接到不同型号的相关更新页面
【发布时间】:2015-04-05 19:50:14
【问题描述】:

我有两个模型,即daily_ward_entrydischarge_note,这两个模型都通过discharge_note.regn_number = daily_ward_entry.ipd_patient_id 关联。我想从daily_ward_entry 创建一个链接以更新discharge_note 上的页面。

我不知道如何创建这样的链接。

我试过这样,但它根本不重定向。

<?= Html::a('Go to Discharge NOte', 
['discharge-note/update', $dischargenote->regn_number =>$model->ipd_patient_id], 
['class' => 'btn btn-primary']) ?>

【问题讨论】:

    标签: php yii2


    【解决方案1】:

    你的错误是不正确的发送参数。使用键值对发送参数。见doc

    <?= Html::a('Go to Discharge NOte', 
    ['discharge-note/update', 'id' => $model->ipd_patient_id], 
    ['class' => 'btn btn-primary']) ?>
    

    【讨论】:

    • 嗨 Vitalik - 我仍然收到 missing parameter id 的错误。根据您的建议生成的 URL 类似于 index.php?r=discharge-note%2Fupdate&amp;regn_number=1
    • 我编辑代码。我将regn_number 更改为id。但我不确定它是否有帮助。因为我不知道你在 urlmanager 中的规则
    猜你喜欢
    • 1970-01-01
    • 2022-07-19
    • 1970-01-01
    • 1970-01-01
    • 2016-09-08
    • 2013-09-13
    • 1970-01-01
    • 2016-04-14
    • 1970-01-01
    相关资源
    最近更新 更多