<?php namespace Anomaly\PagesModule\Page\Form;

use Anomaly\PagesModule\Page\Contract\PageInterface;
use Anomaly\PreferencesModule\Preference\Contract\PreferenceRepositoryInterface;
use Illuminate\Foundation\Bus\DispatchesJobs;

class PageFormFields
{

    use DispatchesJobs;

    /**
     * Handle the page fields.
     *
     * @param PageFormBuilder $builder
     * @param PreferenceRepositoryInterface $preferences
     */
    public function handle(PageFormBuilder $builder, PreferenceRepositoryInterface $preferences)
    {
        $parent = $builder->getParent();

        /* @var PageInterface $entry */
        if (!$parent && $entry = $builder->getFormEntry()) {
            $parent = $entry->getParent();
        }

        $translations = $parent->getTranslations();

        $slugs = $translations->map(
            function ($translation) {

                return [
                    'field'        => 'slug',
                    'locale'       => $translation->locale,
                    'config'       => [
                        'prefix' => $translation->path,
                    ],
                ];
            }
        )->all();

        $builder->setFields(
            array_merge([
                '*',
                'parent'     => [
                    'config' => [
                        'mode'          => 'lookup',
                        'default_value' => $parent ? $parent->getId() : null,
                    ],
                ],
                'publish_at' => [
                    'config' => [
                        'default_value' => 'now',
                        'timezone'      => config('app.timezone'),
                    ],
                ],
            ], $slugs)
        );
    }
}

<?php namespace Anomaly\PagesModule\Page\Form;

use Anomaly\PagesModule\Page\Contract\PageInterface;
use Anomaly\PreferencesModule\Preference\Contract\PreferenceRepositoryInterface;
use Illuminate\Foundation\Bus\DispatchesJobs;

class PageFormFields
{

    use DispatchesJobs;

    /**
     * Handle the page fields.
     *
     * @param PageFormBuilder $builder
     * @param PreferenceRepositoryInterface $preferences
     */
    public function handle(PageFormBuilder $builder, PreferenceRepositoryInterface $preferences)
    {
        $parent = $builder->getParent();

        /* @var PageInterface $entry */
        if (!$parent && $entry = $builder->getFormEntry()) {
            $parent = $entry->getParent();
        }

        $builder->setFields(
            [
                '*',
                'parent'     => [
                    'config' => [
                        'mode'          => 'lookup',
                        'default_value' => $parent ? $parent->getId() : null,
                    ],
                ],
                'publish_at' => [
                    'config' => [
                        'default_value' => 'now',
                        'timezone'      => config('app.timezone'),
                    ],
                ],
            ]
        );

        if ($parent && $translations = $parent->getTranslations()) {
            $builder->setFields(
                array_merge(
                    $builder->getFields(),
                    $translations->map(
                        function ($translation) {

                            return [
                                'field'  => 'slug',
                                'locale' => $translation->locale,
                                'config' => [
                                    'prefix' => $translation->path,
                                ],
                            ];
                        }
                    )->all()
                )
            );
        }
    }
}

Fix issue for root pages
Fix issue for root pages
