[英]Laravel Pass Data To Form on Another Page
I am attempting to essentially pass a variable from one page url to another to assist in filling out a form. 我试图将变量从一个页面URL传递到另一个页面,以协助填写表单。
I have a Script
model and a Prescription
model. 我有一个
Script
模型和一个Prescription
模型。 Each script can have multiple prescriptions. 每个脚本可以有多个处方。 So on the Scripts show page, I'm wanting to have a create button that allows users to click it, and it sends them to the Prescriptions create page, but auto-fills out the
script_id
for the user in the controller. 因此,在“脚本显示”页面上,我希望有一个创建按钮,允许用户单击它,然后将其发送到“处方创建”页面,但会自动在控制器中为用户填写
script_id
。 This way it is definitively tagged to the correct script. 这样,它就可以明确地标记到正确的脚本。
So if someone clicks on 'Create Prescription' on test.com/scripts/34/show
, it takes them to test.com/prescriptions/create
and automatically applies 34
as the script_id
field - ideally either a hidden field, or directly passed to the controller somehow so that the user can't tamper with it. 因此,如果有人在
test.com/scripts/34/show
上单击“创建处方”,则将他们带到test.com/prescriptions/create
并自动将34
用作script_id
字段-理想情况下是隐藏字段,或直接传递给控制器,使用户无法对其进行篡改。
You can use session, before returning prescriptions/create page you can do 您可以使用会话,然后再返回处方/创建页面
Session::flash('script_id', $script_id);
and when user submits prescription creation just take it 当用户提交处方创建时,只需接受
$script_id = Session::get('script_id');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.