英文:
How to create asterisk in material-ui switch component lable?
问题
我传递了一个必需的属性,其中包含一个启用标签中的星号符号的属性,但它没有起作用。
<FormControlLabel
control={
<Switch
onChange={event =>
onChangeRow(
rowIndex,
'name',
event.target.checked === true ? 'Y' : 'N'
)
}
disableRipple
style={{ backgroundColor: 'transparent' }}
checked={row.address.name === 'Y'}
color='primary'
/>
}
labelPlacement='start'
label='Name?'
required={row.formDesc.name.is_mandatory === 'Y'}
disabled={issubmited.value ? disabled : row.formDesc.name.is_editable === 'N'}
error={hasError('name')}
helpertext={getError('name')}
/>
英文:
I'm passing a required props has a property to enable asterisk symbol in label but it not working
<FormControlLabel
control={
<Switch
onChange={event =>
onChangeRow(
rowIndex,
'name',
event.target.checked === true ? 'Y' : 'N'
)
}
disableRipple
style={{ backgroundColor: 'transparent' }}
checked={row.address.name === 'Y'}
color='primary'
/>
}
labelPlacement='start'
label={'Name?'}
required={row.formDesc.name.is_mandatory === 'Y'}
disabled={issubmited.value ? disabled : row.formDesc.name.is_editable === 'N'}
error={hasError('name')}
helpertext={getError('name')}
/>
答案1
得分: 0
以下是翻译好的内容:
在我决定将自定义组件传递给标签并根据需求启用或禁用星号的条件之后。
<FormControlLabel
control={
<Switch
onChange={event =>
onChangeRow(
rowIndex,
'name',
event.target.checked === true ? 'Y' : 'N'
)
}
disableRipple
style={{ backgroundColor: 'transparent' }}
checked={row.address.name === 'Y'}
color='primary'
/>
}
labelPlacement='start'
label={<Typography>Name?{row.formDesc.name.is_mandatory === 'Y' && <span style={{color: 'red', fontSize: '18px'}}>*</span>}</Typography>}
required={row.formDesc.name.is_mandatory === 'Y'}
disabled={issubmited.value ? disabled : row.formDesc.name.is_editable === 'N'}
error={hasError('name')}
helpertext={getError('name')}
/>
英文:
After I have dicidied to pass custom compoenent to the lable with condition to enable disable asterisk depends on requirement.
<FormControlLabel
control={
<Switch
onChange={event =>
onChangeRow(
rowIndex,
'name',
event.target.checked === true ? 'Y' : 'N'
)
}
disableRipple
style={{ backgroundColor: 'transparent' }}
checked={row.address.name === 'Y'}
color='primary'
/>
}
labelPlacement='start'
label={<Typography>Name?{row.formDesc.name.is_mandatory === 'Y' && <span style={{color: 'red', fontSize: '18px'}}>*</span>}</Typography>}
required={row.formDesc.name.is_mandatory === 'Y'}
disabled={issubmited.value ? disabled : row.formDesc.name.is_editable === 'N'}
error={hasError('name')}
helpertext={getError('name')}
/>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论