Magnolia 5.6 reached end of life on June 25, 2020. This branch is no longer supported, see End-of-life policy.
DateFieldDefinition renders a calendar that allows the user to select a date and optionally a time.
class: info.magnolia.ui.form.field.definition.DateFieldDefinition
Simple date field
form: tabs: - name: tabText label: Text fields: - name: date class: info.magnolia.ui.form.field.definition.DateFieldDefinition time: false type: Date label: Date defaultValue: now
Node name | Value |
---|---|
form | |
tabs | |
tabText | |
fields | |
date | |
class | info.magnolia.ui.form.field.definition.DateFieldDefinition |
time | false |
type | Date |
label | Date |
defaultValue | now |
You can use common field properties and the following properties in a date field definition:
Properties:
<field name> | |
| optional, default is Enables time selection. Renders dropdown boxes at the bottom of the calendar. |
| required Set the |
| optional, default is Format in which the date is displayed to users. See SimpleDateFormat class for allowed patterns. Examples: dateFormat: yyyy-MM-dd # 2017-10-31 dateFormat: yyyy-MMMM-dd # 2017-October-31 dateFormat: EEE, MMM d, yyyy # Tue, Oct 31, 2017 |
| optional, default is Format in which time is displayed to users. See SimpleDateFormat class for allowed patterns. Examples: timeFormat: HH:mm # 15:09 timeFormat: h:mm a # 3:09 PM |
| optional, default is Set the default value to a specific date such as The default value only applies to new content items, not to existing content items that have been created previously. Enclose the default value in quotes when using YAML: defaultValue: "2017-10-31" defaultValue: "2017-10-31 15:09" If you define the dateFormat: MM/dd/yyyy timeFormat: h:mm a defaultValue: "10/31/2017 3:09 PM" |
4 Comments
Daniel Stancu
Hello,
I got the following error by editing / creating a new item in an app. I have a date field in the form.
magnolia.ui.form.field.factory.FieldFactoryFactory: No factory class set for definition class [info.magnolia.ui.form.field.definition.DateFieldDefinition$$EnhancerByCGLIB$$90296b1].
Please check your configuration.
Magnolia 5.6.6
magnolia-ui-form 5.6.5
magnolia-ui-dialog 5.6.5
Attached: the form configuration exported as yaml.
'form':
jcr:mixinTypes: ['mix:lockable']
'tabs':
jcr:mixinTypes: ['mix:lockable']
'article':
jcr:mixinTypes: ['mix:lockable']
'fields':
jcr:mixinTypes: ['mix:lockable']
'title':
'class': 'info.magnolia.ui.form.field.definition.TextFieldDefinition'
'i18n': 'true'
'required': 'true'
jcr:mixinTypes: ['mix:lockable']
'description':
'class': 'info.magnolia.ui.form.field.definition.TextFieldDefinition'
'i18n': 'true'
'required': 'true'
'rows': '4'
jcr:mixinTypes: ['mix:lockable']
'active':
'class': 'info.magnolia.ui.form.field.definition.CheckboxFieldDefinition'
'type': 'Boolean'
jcr:mixinTypes: ['mix:lockable']
'image':
'appName': 'assets'
'class': 'info.magnolia.ui.form.field.definition.LinkFieldDefinition'
'targetWorkspace': 'dam'
'identifierToPathConverter':
'class': 'info.magnolia.dam.app.assets.field.translator.AssetCompositeIdKeyTranslator'
'contentPreviewDefinition':
'contentPreviewClass': 'info.magnolia.dam.app.ui.field.DamFilePreviewComponent'
'articleTypes':
'description': 'articles.detail.editor.articleTypes.description'
'extends': '/modules/categorization/dialogs/generic/tabCategorization/fields/categories'
'i18nBasename': 'info.magnolia.module.articles.messages'
'label': 'articles.detail.editor.articleTypes.label'
'required': 'true'
'field':
'targetTreeRootPath': '/article-types'
'domain':
'class': 'info.magnolia.ui.form.field.definition.TextFieldDefinition'
jcr:mixinTypes: ['mix:lockable']
'date':
'class': 'info.magnolia.ui.form.field.definition.DateFieldDefinition'
'defaultValue': 'now'
'required': 'true'
'time': 'false'
'type': 'Date'
'author':
'class': 'info.magnolia.ui.form.field.definition.TextFieldDefinition'
'defaultValue': 'Article Author'
jcr:mixinTypes: ['mix:lockable']
'body':
'alignment': 'true'
'class': 'info.magnolia.ui.form.field.definition.RichTextFieldDefinition'
'configJsFile': '/.resources/qomet-website/ckeditor/config.js'
'i18n': 'true'
'images': 'true'
'required': 'true'
'rows': '50'
'source': 'true'
'tables': 'true'
jcr:mixinTypes: ['mix:lockable']
'keywords':
'class': 'info.magnolia.ui.form.field.definition.TextFieldDefinition'
'i18n': 'true'
'required': 'false'
'rows': '2'
Christoph Meier
Hello Daniel
It is hard to read the YAML if it is not formatted. Can you post the complete app definition e.g. to https://gist.github.com/ or a similar service which can properly render the correct format and then providing the link to that file?
Cheers,
Christoph
Daniel Stancu
I solved the problem by updating to Magnolia 5.7
The yaml exported configuration:
Thank you
Christoph Meier
I have wrapped your link to github into a Expand macro to save some space