2013-10-23 25 views
1

我有一个Wordpress插件,有一些表格和输入表单。这些表格使用标准的Wordpress表widefat类构建。输入表格嵌入到widefat表格中的单元格中。Wordpress Metabox输入表格溢出

在哪里,我只是显示数据,该表调整大小以适应metabox。当我使用的输入字段,表溢出metabox,见图片:

Input forms overrunning WordpressMetabox

我想输入表来调整,如数据表。

这是正常的表是如何呈现:

<table class="widefat" id="item_publication_attributes"> 
    <tr> 
     <th class="type"><b>Type</b></th> 
     <th class="date"><b>Date</b></th> 
     <th class="name"><b>Name</b></th> 
     <th class="address"><b>Address</b></th> 
     <th class="gender"><b>Map</b></th> 
     <th></th> 
    </tr> 
    <tr class="publish-attribute publish-attribute-1"> 
     <td class="type">Publisher</td> 
     <td class="date">15/2/1971</td> 
     <td class="name">Publish Company</td> 
     <td class="location">63 The Street, The Town, Cambridgeshire</td> 
     <td class="map-icon" style="font-size:70%">[map]</td> 
     <td><a href="#" class="publish-attribute-delete" data-id="1">Delete</a> | <a href="#" class="person-edit" data-id="1">Edit</a></td> 
    </tr> 
</table> 

这是形式表如何呈现:

<form> 
<input type="hidden" name="post_id" id="add_publishing_attribute_post_id" value=2624/> 
<table class="widefat" id="add_new_publishing_attribute"> 
    <tr id="add_new_publishing_attribute_row"> 
     <td class="type"> 
      <select name="type" id="add_attribute_type"> 
       <option value="0">ID 0</option> 
       <option value="1">ID 1</option> 
       <option value="2">ID 2</option> 
      </select> 
     </td> 
     <td class="dd"><input type="text" name="dd" id="add_attribute_dd" placeholder="dd" /></td> 
     <td class="mm"><input type="text" name="mm" id="add_attribute_mm" placeholder="mm" /></td> 
     <td class="yyyy"><input type="text" name="yyyy" id="add_attribute_yyyy" placeholder="yyyy" /></td> 
     <td class="name"><input type="text" name="name" id="add_attribute_name" placeholder="name" /></td> 
     <td class="location"><input type="text" name="location" id="add_attribute_location" placeholder="location" /></td>   
     <td><input type="submit" name="submit" id="add_new_attribute_submit" value="Add"/></td> 
    </tr> 
</table> 
</form> 

感谢您的任何建议

+0

我们需要的是你的CSS(style.css文件) – Romain

+0

有没有实际的学风在预定义的Wordpress类“widefat”之外的那一刻。 –

+0

大声笑,所以你需要的是创建一个CSS与你的HTML =) – Romain

回答

2

我不明白的是为什么你在元框中使用表单...我们只是简单地将输入字段放在那里,并且save_post负责其余的部分,here's a full example

要解决表格的布局,我已经找到了答案在这里:Why is my HTML table not respecting my CSS column width?

用途:table-layout:fixed

<table class="widefat" id="add_new_publishing_attribute" style="table-layout:fixed"> 
+0

嗯...我在metabox中使用表单,因为我试图通过metabox输入数据...也就是说,您的答案完美无缺,所以谢谢,但我很想听听它应该如何被做:) –

+1

我已经添加了一个例子,所有的哨子和一个元框需要;)有很多在WPSE,只是搜索['add_meta_boxes + save_post + wp_nonce_field'](http:// wordpress。 stackexchange.com/search?q=%2Badd_meta_boxes+%2Bsave_post+%2Bwp_nonce_field)。 – brasofilo

+0

这很好,你是否雇用:) –