Laravel Backpack PageManager - Can't add page (Field 'template' doesn't have a default value)

Viewed 18

Trying to add a new page in a Laravel BackPack project, using the PageManager addon gives the following error:

SQLSTATE[HY000]: General error: 1364 Field 'template' doesn't have a default value

Expanding the Ignition error message shows the following:


INSERT INTO
  `pages` (
    `name`,
    `title`,
    `slug`,
    `content`,
    `extras`,
    `updated_at`,
    `created_at`
  )
VALUES
  (
    dghj,
    fghj,
    fghj,
    ?,
    { "meta_title": NULL,
    "meta_description": NULL,
    "meta_keywords": NULL },
    2022 -09 -12 16: 19: 59,
    2022 -09 -12 16: 19: 59
  )

...there's no sign of a template in this query but (I believe) it should be added by the PageManager addon so isn't something I have control of.

None of the frames in Ignition show files I've worked on, they're all illuminate or vendor files, however I've set up a new base app containing Laravel, Backpack and Backpack PageManager only, which works as expected so I don't think this is a bug in a package. I'm at a loss as to what I've done wrong or how to go about finding/resolving the problem.

Further info:

  • Selecting a template in the CRUD view DOES prompt the JS pop-up 'Are you sure you want to update the page template', confirming DOES update the URL to include the GET parameter e.g. [domain]/admin/page/create?template=standard
  • PHP Version: 8.1.9
  • Backpack version: 5.3.12
  • I also have the MenuCRUD addon installed which is reliant upon PageManager and is working as expected.
1 Answers

I managed to find the issue.

For whatever reason a view had been published to resources\views\vendor\backpack\crud\fields\select_page_template.blade.php

This file included:

<select class="form-control" id="select_template" name="select_template" ... >

Changing the name to 'template' resolved the issue:

<select class="form-control" id="select_template" name="template" ... >

Neither of these variations match what's in the original version of the file here, which doesn't even include a name attribute on the input. I'm not sure why mine does, but is all seems to be working now so I'll let sleeping dogs lie and leave this page up in case it benefits anybody else.

Related