Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sebastian Dammark 581 posts 1385 karma points
    Dec 04, 2020 @ 14:07
    Sebastian Dammark
    0

    Creating documents, that uses compositions, with Umbraco forms

    I'm trying to create documents in the tree with Umbraco Forms.

    The documenttype have different types of fields, but all fields that comes from a composition doesn't get any data from the form. All other fields do.

    Have anyone else experienced this ?

  • Marc Goodson 2141 posts 14344 karma points MVP 8x c-trib
    Dec 05, 2020 @ 09:57
    Marc Goodson
    1

    Hi Sebastian

    The issue lies in Umbraco Forms

    Essentially it gets all of your posted Form Fields in the workflow step 'SaveAsUmbracoNode'

    It uses the ContentTypeService to get the ContentType that you are trying to create.

    Then uses the ContentService to create a new content item instance based on the ContentType specified.

    Then it loops through all the properties of the newly created content item (which will include all the properties from compositions)...

    and uses the alias of the property to pull the value from the posted Umbraco form fields that match the alias...

    ... however it needs to know 'what type' of property each one is to know how to parse the form field correctly, eg if it's a date field - and so it needs to find the corresponding PropertyType for the property (to find it's DataType), but from the content item it only has the property alias.

    And here's the bug

    It looks up the PropertyType for a property alias, by using the ContentType definition it retrieved initially to create the content item. The ContentType entity has a PropertyTypes property... and it filters this by alias to find the PropertyType.

    But the PropertyTypes property of a ContentType only includes properties from the actual ContentType and not any compositions...

    If the corresponding PropertyType isn't found the mapping is skipped, which is why all your properties from compositions aren't being created, even though they are posted!

    There is a property on ContentType called CompositionPropertyTypes, which could be used instead to lookup the PropertyTypes of compositions properties instead.

    So we could raise this as an issue with Umbraco Forms, or in the meantime, if you create a custom workflow step and inherit from 'SaveAsUmbracoNode' then you should be able to override the Execute status to implement your own version of the step...:-(

    (created issue: https://github.com/umbraco/Umbraco.Forms.Issues/issues/463)

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft