enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
201 stars 34 forks source link

Default value from schema overwrites explicit property value in lib-content.create() #8149

Closed alansemenov closed 4 years ago

alansemenov commented 4 years ago

Content type schema:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<content-type>
  <display-name>Date</display-name>
  <super-type>base:structured</super-type>
  <form>
    <input name="date" type="Date">
      <label>Date</label>
      <indexed>true</indexed>
      <occurrences minimum="1" maximum="1"/>
      <default>2000-01-01</default>
    </input>
  </form>
</content-type>

Create new content of this type:

var contentLib = require('/lib/xp/content');

var content = contentLib.create({
    name: 'myContent',
    parentPath: '/',
    displayName: 'My Content',
    contentType: 'com.enonic.app.mytype:date',
    data: {
        "date": "2020-06-02"
    }
});

Here we explicitly say that the new content should have value 2020-06-02 in the date field, but content is still created with default value 2000-01-01

alansemenov commented 4 years ago

NB! Check if we have this problem for other input types where we support default values as well.

sgauruseu commented 4 years ago

I verified this bug manually. I am planning to add ui-test for this bug