Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

radio 在Form中使用初始值不管用 也无法操作选中其他值 #317

Closed
ahua52 opened this issue Aug 20, 2019 · 2 comments
Closed

Comments

@ahua52
Copy link
Contributor

ahua52 commented Aug 20, 2019

环境及版本信息

  • tinper-bee 版本号:
  • 若使用单个组件,请标明该组件版本号:
  • 当前项目中react的版本号:
  • 所使用的操作系统:
  • 所使用的浏览器:

描述这个问题:

代码

在Form里使用
<Radio.RadioGroup
{
...getFieldProps('vnote', {
initialValue: '1',
}
) }
>


</Radio.RadioGroup>

报错信息

页面上没有否没有被选中 也不能选中是选项

当前的行为:效果(可截图说明)及动作描述

期望的行为:

@a982027400
Copy link

/**

import React, { Component } from 'react'
import Radio from 'bee-radio'
import Form from 'bee-form';
const FormItem = Form.FormItem;

class Demo2 extends Component{
constructor(props) {
super(props);
this.state = {
selectedValue: '3'
};
}
handleChange = (value) => {
this.setState({selectedValue: value});
}

onSubmit = () => {
this.props.form.validateFields((err, _values) => {
console.log(_values);
});
}

onRest = () => {
	this.props.form.resetFields();
	this.props.form.validateFields((err, _values) => {
		console.log(_values);
	});
}

render() {
let { selectedValue } = this.state;
let { form: { getFieldProps } } = this.props;

return (
  <FormItem>
    <Radio.RadioGroup
      name="color"
      {...getFieldProps('vnote', { initialValue: selectedValue, })}
      selectedValue={selectedValue}
      onChange={this.handleChange}
    >
        <Radio colors="primary" value="1" >苹果</Radio>
        <Radio colors="success" value="2" >香蕉</Radio>
        <Radio colors="info" value="3" >葡萄</Radio>
        <Radio colors="warning" value="4" >菠萝</Radio>
        <Radio colors="danger" value="5" >梨</Radio>
        <Radio colors="dark" value="6" >石榴</Radio>
    </Radio.RadioGroup>
    <button onClick={this.onSubmit}>提交</button>
    <button onClick={this.onRest}>清空</button>
  </FormItem>
)

}
};

export default Form.createForm()(Demo2);

你按这种写法试一下,我这边没问题

@yurokn
Copy link
Collaborator

yurokn commented Aug 22, 2019

  • bee-radio@2.0.15
    • [ Fixbug ]解决了当bee-form包裹时,选中项不能显示的问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants