无法通过窗体小部件中的标签文本选择单选按钮

时间:2017-08-28 11:45:37

标签: wordpress

我无法通过窗体小部件中的标签文本选择单选按钮。 MDN推荐以下代码,并且在jsFiddle中工作正常,但在WordPress的窗口小部件表单区域中没有。

public get user() Observable<User> {
  return this.loginService.getMessage();
}

Wordpress小部件区域发生了什么以更改此功能?

感谢。

编辑:此代码放在扩展WP_Widget的类中的form方法中。它是此处https://codex.wordpress.org/Widgets_API

中示例的修改版本

小提琴:以下是浏览器https://jsfiddle.net/n2fole00/xjo86zc7/的输出,如您所见,它可以在jsFiddle中运行,但不能在Wordpress小部件面板中运行。

1 个答案:

答案 0 :(得分:0)

<p>
    <input type="radio" id="channel_id" name="<?php echo esc_attr( $this->get_field_name( 'channel_type' ) ); ?>" value="channelid" <?php echo ($this->get_field_name( 'channel_type' ) == 'channelid') ? 'checked' : ''; ?>>
    <label for="channel_id">Channel ID</label><br>
    <input type="radio" id="channel_name" name="<?php echo esc_attr( $this->get_field_name( 'channel_type' ) ); ?>" value="channel" <?php echo ($this->get_field_name( 'channel_type' ) == 'channel') ? 'checked' : ''; ?>>
    <label for="channel_name">Channel name</label>
</p>