[posts-module] Can't assign custom fields to a post type
Created 7 years ago by josebarbosa

Hello,

I can't assign custom fields to a post type, I only see the option to add a new field. But in pages module I can do it just fine. What I'm doing wrong ?

Print screen: https://dl.dropboxusercontent.com/u/8369635/posts.png

ryanthompson  —  7 years ago

Hey there! Go to Types then click Assignments next to the type you want to assign fields to.

This pattern is the exact same (other than being called "Types" maybe) throughout so you'll know where to find it next time 😊

josebarbosa  —  7 years ago

I'm missing something :/.

I click on Assignments near the "Default" type (the only one that I have right now) and then I'm redirected to the page that I showed to you above. I don't see any assign field button there.

https://dl.dropboxusercontent.com/u/8369635/posts2.png

ryanthompson  —  7 years ago

Uhhh.. that's super weird:

https://cl.ly/0U2A191y010j

Are you getting an actual redirect in the response or just.. this is what's loading?

Im on v2.2.14 for posts-module - what are you?

ryanthompson  —  7 years ago

Also what's your environment / stack?

josebarbosa  —  7 years ago

My dev environment: MAMP PRO (macOS), PHP v5.6.7, All PyroCMS requirements are met.

Ryan I think that I've found the problem. In the file: /core/anomaly/posts-module/src/PostsModule.php, I move the sections/assignments array from fields to types as follows:

posts-module: v2.2.14 https://github.com/anomalylabs/posts-module/blob/master/src/PostsModule.php

...
'types'      => [
            'buttons' => [
                'new_type',
            ],
            'sections' => [
                'assignments' => [
                    'href'    => 'admin/posts/fields/assignments/{request.route.parameters.stream}',
                    'buttons' => [
                        'assign_fields' => [
                            'data-toggle' => 'modal',
                            'data-target' => '#modal',
                            'href'        => 'admin/posts/fields/assignments/{request.route.parameters.stream}/choose',
                        ],
                    ],
                ],
            ],
        ],
        'fields'     => [
            'buttons'  => [
                'new_field' => [
                    'data-toggle' => 'modal',
                    'data-target' => '#modal',
                    'href'        => 'admin/posts/fields/choose',
                ],
            ],
        ],
...

Everything seems fine now 😄.

ryanthompson  —  7 years ago

Can you open a PR with a bug report on this so I can test more. Thanks!

idlethumbs  —  7 years ago

Exact same issue just cropped up for me trying to add fields to my new post type. Will try Jose's fix

ryanthompson  —  7 years ago

This was recently fixed in Posts / Platform. It was an an issue with the href matcher. Should be resolved now if you composer update.