这可能已经是另一个问题的副本,但我找不到。
我的表格中有一个动作:
<form id="bug-form" action="/AST_14/Bugg.ly2/index.php/bug/update/" method="post">
现在我的系统工作方式是每个&#34;错误&#34;需要更新的那里有自己的bug id,通常情况下这会进入bug ID的末尾,以允许用户更新所述Bug。
我在Yii中创建了一些json代码来显示错误ID和编辑。 问题是当我点击编辑时。它转到一个页面,表单上没有ID。我需要一些方法来获取该ID以移动到表单。
以下是我对表单的所有代码。
<!--PAGE -->
<div data-role="page" id="Reg">
<header role="banner" data-role="header" id="header" style="height:45px; z- index:1"> <a data-icon="back" data-role="button" data-rel="back" class="ui-btn- left backToAdmin">Back</a> </header>
<!--Initial Home Screen Logo-->
<section data-role="content" class="constrain headerLogo" > </section>
<!--Main Content in Center of Screen-->
<section data-role="content" class="sectionContent constrain">
<!--960 Grid Root [responsive web design plugin]-->
<div class="container_16" data-theme="a">
<div class="grid_16">
<div class="gridMarginsLeft">
<ul id="viewProps" data-role="listview" data-inset="true" data-theme="a" data-icon="false" class="">
<li data-role="list-divider" data-theme="a"><span class="icon-data fontIcons"></span><span class="coloumnHeaders">Update</span></li>
<li data-role="list-divider" data-theme="a">
<form id="bug-form" action="/AST_14/Bugg.ly2/index.php/bug/update/" method="post">
<p class="note">Fields with <span class="required">*</span> are required.</p>
<div class="row">
<label for="Bug_bugname">Bugname</label> <textarea rows="6" cols="50" name="Bug[bugname]" id="Bug_bugname">1</textarea> </div>
<div class="row">
<label for="Bug_BugType">Bug Type</label> <input name="Bug[BugType]" id="Bug_BugType" type="text" value="1"> </div>
<div class="row">
<label for="Bug_Bugaddress">Bugaddress</label> <input size="60" maxlength="255" name="Bug[Bugaddress]" id="Bug_Bugaddress" type="text" value="1"> </div>
<div class="row">
<label for="Bug_description">Description</label> <textarea rows="6" cols="50" name="Bug[description]" id="Bug_description">1</textarea> </div>
<div class="row">
<label for="Bug_admin_id">Admin</label> <input name="Bug[admin_id]" id="Bug_admin_id" type="text" value="1"> </div>
<div class="row">
<label for="Bug_status">Status</label> <input size="3" maxlength="3" name="Bug[status]" id="Bug_status" type="text" value="1"> </div>
<div class="row">
<label for="Bug_type">Type</label> <input size="20" maxlength="20" name="Bug[type]" id="Bug_type" type="text" value="1"> </div>
<div class="row">
<label for="Bug_vendors_id">Vendors</label> <input name="Bug[vendors_id]" id="Bug_vendors_id" type="text" value="1"> </div>
<div class="row buttons">
<input type="submit" name="yt0" value="Save"> </div>
</form>
</li>
</ul>
</div>
</div>
</div>
答案 0 :(得分:1)
向表单添加隐藏的输入。我的id是变量名$ id:
form id="bug-form" action="/AST_14/Bugg.ly2/index.php/bug/update/" method="post">
<input type="hidden" name="id" value="$id" />
</form>
要将ID放在URL路径中,请将$ id附加到操作路径。
form id="bug-form" action="/AST_14/Bugg.ly2/index.php/bug/update/$id" method="post">
答案 1 :(得分:0)
在表单中添加隐藏的输入字段标记,并将id作为其值。
listview
并使用javascript / jquery代码更改您的操作网址(这里我使用了jquery):
(文档)$。就绪(函数(){
<input type="hidden" id="bug_id" name="bug_id" value="$id" />
});