This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

philipptempel
philipptempel

Hello everyone, just started evaluating OctoberCMS for our use case with the following setup:

Imagine my own plugin Acme\Testing which has two models: Model\Post with belongsTo Model\Category which in turn hasMany Model\Post. Creating the basic forms for both models on the backend was quite easy due to the wonderful screencasts by Samuel.

The Model\Post's fields.yaml looks like

fields
    # Other fields here
    category:
            label: Category
            type: partial
            path: field_category

The config_relation.yaml of RelationController looks like

category:
    label: Category
    view:
        list:
            columns:
                id:
                    label: ID
                title:
                    label: Title
        form:
            fields:
                id:
                    label: ID
                    type: hidden
                    hidden: true
                    required: true
                title:
                    label: Title
                    comment: Name of the assigned category
                    type: text
        toolbarButtons: link|create
    manage:
        list: $/acme/testing/models/category/columns.yaml
        form: $/acme/testing/models/category/fields.yaml
        showSearch: true
        recordsPerPage: 10
        defaultSort:
            column: title
            direction: asc

However, it does not do what I want it to do.

What I am trying to achieve is the following behavior

  1. Create a new post which must have a category for it to be successfully created
  2. The category can be linked i.e., chosen, or created when it does not exist
  3. On save, the post will be saved with its assigned category

This topic might relate to http://octobercms.com/forum/post/backend-forms-and-relations, however, I didn't find any solution there. Did I miss something in the docs or is this kind of behavior not supported with the RelationController?

Last updated

st.james.jomuad13119
st.james.jomuad13119

philipptempel said:

Hello everyone, just started evaluating OctoberCMS for our use case with the following setup:

Imagine my own plugin Acme\Testing which has two models: Model\Post with belongsTo Model\Category which in turn hasMany Model\Post. Creating the basic forms for both models on the backend was quite easy due to the wonderful screencasts by Samuel.

The Model\Post's fields.yaml looks like

fields
   # Other fields here
   category:
           label: Category
           type: partial
           path: field_category

The config_relation.yaml of RelationController looks like

category:
   label: Category
   view:
       list:
           columns:
               id:
                   label: ID
               title:
                   label: Title
       form:
           fields:
               id:
                   label: ID
                   type: hidden
                   hidden: true
                   required: true
               title:
                   label: Title
                   comment: Name of the assigned category
                   type: text
       toolbarButtons: link|create
   manage:
       list: $/acme/testing/models/category/columns.yaml
       form: $/acme/testing/models/category/fields.yaml
       showSearch: true
       recordsPerPage: 10
       defaultSort:
           column: title
           direction: asc

However, it does not do what I want it to do.

What I am trying to achieve is the following behavior

  1. Create a new post which must have a category for it to be successfully created
  2. The category can be linked i.e., chosen, or created when it does not exist
  3. On save, the post will be saved with its assigned category

This topic might relate to http://octobercms.com/forum/post/backend-forms-and-relations, however, I didn't find any solution there. Did I miss something in the docs or is this kind of behavior not supported with the RelationController?

Any updates?

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.