Devise ships with a bunch of useful fields for you to drop in to your slices.
Checkbox
The checkbox field is for boolean (true / false) values in your website:
@section('template')
<div v-if="devise.myCheckbox.checked">
Hey! That checkbox must be on!
</div>
@endsection
@section('component')
<script>
var component = {
fields: {
myCheckbox: {
type: 'checkbox',
label: 'My Checkbox'
}
}
}
</script>
@endsection
Color
Loads a color picker and returns a hex value
@section('template')
<div :style="{backgroundColor: devise.myColor.color}">
The background color you chose is a very good choice!
</div>
@endsection
@section('component')
<script>
var component = {
fields: {
myColor: {
type: 'color',
label: 'My Color'
}
}
}
</script>
@endsection
Date/Time
Loads a date / time picker and returns a string. The format option is modeled after the Momentjs api. Devise actually uses the smaller dayjs but the API is the same. See options here
@section('template')
<div>
The date selected is: @{{ devise.date.text }}
</div>
@endsection
@section('component')
<script>
var component = {
fields: {
myDate: {
type: 'datetime',
label: 'My Date',
settings: {
date: true, // Hide / Show the Calendar
time: true, // Hide / Show the Time Picker
format: 'MMMM D, YYYY h:mm' // Optional format
}
}
}
}
</script>
@endsection
Loads a field to put the address of an image or select an image from the media manager. If you use the media manager you can select a source image and Devise will resize and attempt to optimize the image. Below are a few examples of how to utilize some different scenarios
Responsive images can be accessed via the media property. Example: devise.someImage.media.large which you could use. However, Devise ships with a directive that makes choosing the image automagic.
The select field gives you an opportunity to give the content manager a chance to change values that might effect layout, or maybe, just print out the value. Below shows how you could implement a dynamic v-bind class and print out it's value.