Jump to content

Creating new page from API requires name value


apeisa
 Share

Recommended Posts

Not sure if I am dreaming here, but was'n page creating in API working with just title at some point (it created name automatically from title). I just updated one project to latest and my "used to work nicely" code now cries:

Error Uncaught exception 'WireException' with message 'Can't save page 0: /asiasanat//: It has an empty 'name' field' in /data/www/testi.potilaanlaakarilehti.fi/doc/wire/core/Pages.php:463

Code that used to work and now doesn't is:

$t = new Page();
$t->template = $templates->get("tag");
$t->parent = $pages->get(1011); // 1011 => /asiasanat/
$t->title = $tag;
$t->save();

Fix is of course simple, but I used to like this shorter way to create pages...

EDIT: Never mind, it does work. It doesn't work if your $tag is actually empty string... :)

Edited by apeisa
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...