Skip to content

Commit

Permalink
Merge pull request mrmonat#38 from andypa/master
Browse files Browse the repository at this point in the history
  • Loading branch information
mrmonat authored Oct 22, 2019
2 parents 56157d9 + 3624d66 commit 986e616
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

25 changes: 22 additions & 3 deletions resources/js/components/FormField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
<field-wrapper>
<div class="w-1/5 px-8 py-6">
<slot>
<form-label :for="field.name">
{{ field.name }}
<form-label
:label-for="field.attribute"
:class="{ 'mb-2': showHelpText && field.helpText }"
>
{{ fieldLabel }}

<span v-if="field.required" class="text-danger text-sm">{{
__('*')
}}</span>
</form-label>
</slot>
</div>
Expand Down Expand Up @@ -144,7 +151,19 @@ export default {
'w-1/2': !this.field.trix,
'w-4/5': this.field.trix
}
}
},
/**
* Return the label that should be used for the field.
*/
fieldLabel() {
// If the field name is purposefully an empty string, then let's show it as such
if (this.fieldName === '') {
return ''
}
return this.fieldName || this.field.singularLabel || this.field.name
},
}
}
</script>

0 comments on commit 986e616

Please sign in to comment.