2015-04-20 30 views
0

我有一個表單頁面,當我提交此表的所有輸入,不同的是這一次成功發佈:<input>元素不發佈數據?

<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" 
    <?php if($this->data['kullanici_id']){echo 'readonly';} ?> 
    value="<?php echo $this->data['kullanici_id']?>"> 

但是,爲什麼?

- 這是我的一個.phtml文件:

<html> 
<head> 

</head> 
<body> 
<form enctype="multipart/form-data" action="/admin/kaydet" method="post" onSubmit="javascript: beforeSubmit();"> 
    <?php if(strlen($this->data['id'])):?> 
     <input type="hidden" name="id" value="<?php echo $this->data['id']?>"> 
    <?php endif;?> 
    <font color="green"><h3>DÜZENLE</h3></font> 
    <img src="/foto/<?php echo $this->data['fotograf']?>" height="110" width="110" align="left" /> 
    <table class="table"> 
     <tr> 
      <td>T.C. Kimlik No.:</td> 
      <td><input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?> value="<?php echo $this->data['kullanici_id']?>"></td> 
     </tr> 
     <?php if(!strlen($this->data['id'])):?> 
     <tr> 
      <td>Parola:</td> 
      <td><input id="password2" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td> 
     </tr> 
      <tr> 
       <td>Parola Tekrar:</td> 
       <td><input onchange="passwordCheck(this.value)" class="form-control" type="password" name="parola" value="<?php echo $this->data['parola']?>"></td> 
     </tr> 
     <?php endif; ?> 
    </table> 
    <td><button type="submit" class="btn btn-success btn-sm glyphicon glyphicon-floppy-disk">KAYDET</button> </td> 
</form> 
</body> 
</html> 

如果我有一個id;頁面看起來像編輯成員頁面,如果我沒有;頁面將添加一個新成員。在id =「TC」輸入中,如果我編輯了一個成員,這個輸入不應該改變,所以我添加一個readonly來解決這個問題。但是當我提交時,輸入不會發布。 對不起我的英文不好:D

+0

似乎像場被設置爲'readonly',因此任何更改將被丟棄,並張貼到服務器。您可能想向我們展示實際文章的外觀。 –

+0

請發佈完整的源代碼。 – Noman

+0

@IsaacKleinman,因爲在給定的代碼中只有'readonly''''' disabled''。所以它肯定會被處理 –

回答

0

你的領域沒有被提交的原因是因爲它的設置爲readonly

原因是'如果用戶無法更改字段,則無需提交它,因爲值始終保持不變'。緩解這種行爲

一種方法是添加隱藏字段名稱相同

<input type="hidden" name="kullanici_id" value="<?php echo $this->data['kullanici_id']?>"> /> 
<input id="TC" class="form-control" name="kullanici_id" type="text" onchange="edit()" <?php if($this->data['kullanici_id']){echo 'readonly';} ?> value="<?php echo $this->data['kullanici_id']?>" />