You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Form,Input,Select,Button}from'antd';constFormItem=Form.Item;constOption=Select.Option;classPriceInputextendsReact.Component{staticgetDerivedStateFromProps(nextProps){// Should be a controlled component.if('value'innextProps){return{value: nextProps.value||{},};}returnnull;}constructor(props){super(props);constvalue=props.value||{};this.state={number: value.number||0,currency: value.currency||'rmb',};}handleNumberChange=(e)=>{constnumber=parseInt(e.target.value||0,10);if(isNaN(number)){return;}if(!('value'inthis.props)){this.setState({ number });}this.triggerChange({ number });}handleCurrencyChange=(currency)=>{if(!('value'inthis.props)){this.setState({ currency });}this.triggerChange({ currency });}triggerChange=(changedValue)=>{// Should provide an event to pass value to Form.constonChange=this.props.onChange;if(onChange){onChange(Object.assign({},this.state,changedValue));}}render(){const{ size }=this.props;conststate=this.state;return(<span><Inputtype="text"size={size}value={state.number}onChange={this.handleNumberChange}style={{width: '65%',marginRight: '3%'}}/><Selectvalue={state.currency}size={size}style={{width: '32%'}}onChange={this.handleCurrencyChange}><Optionvalue="rmb">RMB</Option><Optionvalue="dollar">Dollar</Option></Select></span>);}}classDemoextendsReact.Component{handleSubmit=(e)=>{e.preventDefault();this.props.form.validateFields((err,values)=>{if(!err){console.log('Received values of form: ',values);}});}checkPrice=(rule,value,callback)=>{if(value.number>0){callback();return;}callback('Price must greater than zero!');}render(){const{ getFieldDecorator }=this.props.form;return(<Formlayout="inline"onSubmit={this.handleSubmit}><FormItemlabel="Price"extra="test!!!">{getFieldDecorator('price',{initialValue: {number: 0,currency: 'rmb'},rules: [{validator: this.checkPrice}],})(<PriceInput/>)}</FormItem><FormItem><Buttontype="primary"htmlType="submit">Submit</Button></FormItem></Form>);}}constWrappedDemo=Form.create()(Demo);ReactDOM.render(<WrappedDemo/>,mountNode);
What is expected?
错误信息和提示文案同时出现
What is actually happening?
提示文案被覆盖
The text was updated successfully, but these errors were encountered:
Version
3.10.1
Environment
win10, chrome 69.0.3497.100 (64)
Reproduction link
https://ant.design/components/form-cn/#components-form-demo-customized-form-controls
Steps to reproduce
Form 的 layout="inline"
Form.Item 的 extra="test!!!"
按下Submit
错误信息和提示文案无法同时出现,会被覆盖。
What is expected?
错误信息和提示文案同时出现
What is actually happening?
提示文案被覆盖
The text was updated successfully, but these errors were encountered: