Codeigniter Form Helper复制from_hidden?

时间:2011-03-12 01:30:11

标签: forms codeigniter

我完全难过..我使用CI表单助手创建一些表单元素,并且由于一些奇怪的原因,它创建了一个重复版本。

这是我的PHP


<div id="receiveInventoryItemDetails">

        <p><?php echo form_open('#', array("class" => "nyroModal form label-inline"));?></p>

        <?php echo form_hidden('item_id', '', "readonly = true"); ?>
        <?php echo form_hidden('purchase_order_id', '', "readonly = true"); ?>

        <p><?php echo form_label('Item Name', 'item_name');?><?php echo form_input('item_name', '', "readonly = true"); ?></p>

        <p><?php echo form_label('Item QTY', 'item_qty');?><?php echo form_input('item_qty', ''); ?></p>
        <?php echo form_close();?>
</div>
<div class="buttonrow">
    <button class="btn-sec" onclick="inventoryC.receiveSubmitItem();"><span>Add To Inventory</span></button>
</div>

这是HTML输出


<div id="receiveInventoryItemDetails">

    <p><form action="https://mysite.com/#.abl" method="post" accept-charset="utf-8" class="nyroModal form label-inline"></p>

    <input type="hidden" name="item_id" value="" />
    <input type="hidden" name="item_id" value="" />
    <input type="hidden" name="purchase_order_id" value="" />

    <p><label for="item_name">Item Name</label><input type="text" name="item_name" value="" readonly = true /></p>

    <p><label for="item_qty">Item QTY</label><input type="text" name="item_qty" value=""  /></p>
    </form>                             
</div>
<div class="buttonrow">
    <button class="btn-sec" onclick="inventoryC.receiveSubmitItem();"><span>Add To Inventory</span></button>
</div>

1 个答案:

答案 0 :(得分:1)

您不能通过第三个参数使用html属性。查看表单助手source code

这应该是有效的:

<?php echo form_hidden('item_id', ''); ?>