是否可以在 odoo 12 中使用单选按钮旁边的图标
Is it possible to use icons next to radio buttons in odoo 12
I want to put in my form multiple radio boxes each one has a descriptif icon next to it . Is it possible to do it with odoo forms if so how can accomplish it.
你需要用js来实现。
首先找到你收音机的每个节点,
例如,我有一个像这样的 DOM(请使用浏览器开发工具)。
<div class="o_field_radio o_vertical o_field_widget in_out" name="in_out" style="width:70px;">
<div class="o_radio_item">
<input class="o_radio_input" type="radio" data-index="0" data-value="I" id="radio7_I">
<label class="o_form_label" for="radio7_I">Import</label>
</div>
<div class="o_radio_item">
<input class="o_radio_input" type="radio" data-index="1" data-value="O" id="radio7_O">
<label class="o_form_label" for="radio7_O">Outgoing</label>
</div>
</div>
var icon1 = "<span class='glyphicon glyphicon-ok'>";
var icon2 = "<span class='glyphicon glyphicon-remove'>";
// there are icons in bootstrap:
// https://getbootstrap.com/docs/3.3/components/#glyphicons
var first_node = $('div.o_radio_item input[data-value="I"]');
var second_node = $('div.o_radio_item input[data-value="O"]');
first_node.before(icon1);
second_node.before(icon2);
然后将此 js 代码插入您的模板中。
结果
I want to put in my form multiple radio boxes each one has a descriptif icon next to it . Is it possible to do it with odoo forms if so how can accomplish it.
你需要用js来实现。 首先找到你收音机的每个节点, 例如,我有一个像这样的 DOM(请使用浏览器开发工具)。
<div class="o_field_radio o_vertical o_field_widget in_out" name="in_out" style="width:70px;">
<div class="o_radio_item">
<input class="o_radio_input" type="radio" data-index="0" data-value="I" id="radio7_I">
<label class="o_form_label" for="radio7_I">Import</label>
</div>
<div class="o_radio_item">
<input class="o_radio_input" type="radio" data-index="1" data-value="O" id="radio7_O">
<label class="o_form_label" for="radio7_O">Outgoing</label>
</div>
</div>
var icon1 = "<span class='glyphicon glyphicon-ok'>";
var icon2 = "<span class='glyphicon glyphicon-remove'>";
// there are icons in bootstrap:
// https://getbootstrap.com/docs/3.3/components/#glyphicons
var first_node = $('div.o_radio_item input[data-value="I"]');
var second_node = $('div.o_radio_item input[data-value="O"]');
first_node.before(icon1);
second_node.before(icon2);
然后将此 js 代码插入您的模板中。
结果