Skip to content

Commit

Permalink
perf: api can set radio and checkbox tip
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuler authored and BaiJiangJie committed Sep 6, 2024
1 parent 7b9627a commit 5a94ddd
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/components/Form/AutoDataForm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,22 +197,32 @@ export class FormFieldGenerator {
return field
}

afterGenerateField(field) {
field.label = toSentenceCase(field.label)

if (field.placeholder) {
field.el.placeholder = field.placeholder
}

setChoicesTips(field, fieldMeta, fieldRemoteMeta) {
// 设置 checkbox 的 tips
if (field.tips && ['checkbox-group', 'radio-group'].indexOf(field.type) !== -1) {
if (['checkbox-group', 'radio-group'].indexOf(field.type) !== -1) {
field.options.map(option => {
if (!option.tip && field.tips[option.value]) {
if (!option.tip && field.tips) {
option.tip = field.tips[option.value]
}
if (!option.tip) {
const match = option.label.match(/^(.+?)\s*\((.*?)\)$/)
if (match) {
option.label = match[1]
option.tip = match[2]
}
}
})
}
}

afterGenerateField(field) {
field.label = toSentenceCase(field.label)

if (field.placeholder) {
field.el.placeholder = field.placeholder
}

this.setChoicesTips(field)
return field
}

Expand Down

0 comments on commit 5a94ddd

Please sign in to comment.