Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Title will not save in templates #104

Open
stuartcusackie opened this issue Aug 15, 2023 · 5 comments
Open

Title will not save in templates #104

stuartcusackie opened this issue Aug 15, 2023 · 5 comments

Comments

@stuartcusackie
Copy link

stuartcusackie commented Aug 15, 2023

I've recently upgraded to Nova4, along with upgrading all nova packages, including nova-page.

Now I have a problem where I cannot save the page template title. I have checked my migrations and config and they match the current versions. I have also checked that my template file structures match.

I only noticed this problem when I created a new template. My old page templates stayed the same so I did not notice there.

Everything else saves, just not the title. I tried downgrading but 0.3.2 didn't work at all.

@metadeck
Copy link

metadeck commented Aug 15, 2023

I'm having the same issue. Upgraded this morning.

My error message is

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'title' cannot be null (Connection: mysql, SQL: insert into `static_pages` (`name`, `title`, `type`, `attributes`, `created_at`, `updated_at`) values (pages.home, ?, route, {\"nova_page_title\":\"Home\",\"nova_page_created_at\":\"2023-08-15T16:02:09.000Z\",\"seo_description\":\"test\",\"header_text\":\"test\",\"header_description\":\"test\"}, 2023-08-15 15:03:25, 2023-08-15 15:03:25))

Checking through the source I can see that title is now nullable which is wasn't to begin with.

Schema::create('static_pages', function (Blueprint $table) {
            $table->increments('id');
            $table->string('type');
            $table->string('name');
            $table->string('title')->nullable();
            $table->json('attributes');
            $table->timestamps();
});

Looking at the request tab nova_page_title and nova_page_created_at are now stored in the attributes column.
Was there a migration guide between versions that I missed out on?

TIA

@jahvi
Copy link

jahvi commented Aug 24, 2023

Running into this issues as well, it looks like the title does get saved as an attribute just fine but it won't display in the admin or when using Page::title() or @get('title') in blade templates.

Even though the title gets saved as nova_page_title doing something like @get('nova_page_title') doesn't work either.

@brightlabscomau
Copy link

Same issue here. The title attribute does not get populated on the index/edit/detail views within Nova also. Any chance on getting this fixed? I will need to either downgrade or fork this as we will soon be using this in production.

@brightlabscomau
Copy link

brightlabscomau commented Nov 26, 2023

If this helps anyone.. I resolved this (temporarily) by using an observer on the page model that updates the model with the title attribute.

if ($novaPageTitle = request('nova_page_title')) { $page->updateQuietly(['title' => $novaPageTitle]); }

@bingogg14
Copy link

Workaround by overriding the Template and two methods

<?php

namespace App\Nova\NovaPages\Templates;

use Whitecube\NovaPage\Pages\Template as TemplateWhiteCube;

abstract class Template extends TemplateWhiteCube
{
    public function getTitle($default = null, $prepend = '', $append = ''): string
    {
        $this->title = $this->attributes['nova_page_title'];

        return parent::getTitle($default, $prepend, $append);
    }

    public function fill(array $data = []): void
    {
        if (empty($data['title'])) {
            $data['title'] = $data['attributes']['nova_page_title'];
        }

        parent::fill($data);
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants