Reputation: 1489
This is my FormItem
<FormItem label="Rate">
{getFieldDecorator('ORSalesAndPurchaseSalesPrice', {
initialValue: "",
})(
<Input placeholder="Rate(0.00)"/>
)}
</FormItem>
The condition I need is
if(value.ItemTpeId ==1)
<Input placeholder="Rate(0.00)"/>
else
<Input placeholder="Rate(%)"/>
How should I apply this logic for placeholder inside FormItem
?
I also need validation to this field so that only numbers and a decimal point is allowed.
Upvotes: 1
Views: 1721
Reputation: 3520
Let's take Rate in one variable
const rate = (value.ItemTpeId===1) ? "Rate(0.00)" : "Rate(%)";
And add that in to return
<FormItem label="Rate">
{getFieldDecorator('ORSalesAndPurchaseSalesPrice', {
initialValue: "",
})(
<Input placeholder={rate}/>
)}
</FormItem>
Hope this helps!
Upvotes: 2
Reputation: 5422
Use ternary operator.
<Input placeholder={value.ItemTpeId === 1 ? "Rate(0.00)" : "Rate(%)"}/>
Upvotes: 3