【问题标题】:I can't prefill the HTML form with embed url我无法使用嵌入 url 预填充 HTML 表单
【发布时间】:2020-03-03 19:07:23
【问题描述】:

我正在开发一个移动应用程序并为此应用程序创建一个管理面板。我想在 web 中创建一个带有 html 表单的视频对象,并从移动应用程序中获取它。我可以用 html 形式创建这个视频对象。我想通过预填充视频创建表单来使用 html 表单更新此对象,除了嵌入 url 输入文本之外,所有字段都已预填充。由于嵌入 url 包含 ' " ' (双引号) 发生错误。这是我的 html 更新表单:

   <div class="form-group">
                                    <label for="egzersizVideoUrl">Video Embed Url</label>
                                    <input type="url" class="form-control"
                                           name="egzersizVideoUrl" id="egzersizVideoUrl"
                                           value="<?php echo $exercise['video_embed_url']; ?>">
                                </div>
                                <div class="form-group">
                                    <label for="egzersizPopularite">Popülarite Skoru</label>
                                    <input type="text" class="form-control"
                                           name="egzersizPopularite" id="egzersizPopularite"
                                           value="<?php echo $exercise['popularity']; ?> ">
                                </div>

这就是结果

Update form resut

我想用 youtube 嵌入 url 预填充输入字段,我该如何以正确的方式做到这一点?

【问题讨论】:

    标签: php html forms


    【解决方案1】:

    编辑:抱歉,您正在寻找的是 htmlentities

    <input type="url" class="form-control" name="egzersizVideoUrl" id="egzersizVideoUrl" value="<?php echo htmlentities($exercise['video_embed_url']); ?>">
    

    这会将任何双引号转换为相应的 html 实体。

    【讨论】:

    • 感谢您的回复,但在这个版本中,它只添加了一个斜线,结果现在是
    • @ErtuğrulUzun 抱歉,已更新答案 - 你可以试试吗?
    • 现在可以了,非常感谢。由于我的声誉,我无法对答案投赞成票。
    • @ErtuğrulUzun 没问题!如果您需要再次解码字符串,请查看 html_entity_decode()
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-01
    • 1970-01-01
    • 2021-08-07
    • 1970-01-01
    • 2011-07-22
    • 2015-06-24
    相关资源
    最近更新 更多