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

Error saving entries of type single from frontend ajax request #2687

Closed
Anubarak opened this issue Apr 5, 2018 · 1 comment
Closed

Error saving entries of type single from frontend ajax request #2687

Anubarak opened this issue Apr 5, 2018 · 1 comment

Comments

@Anubarak
Copy link
Contributor

Anubarak commented Apr 5, 2018

Description

Single Entries created in the CP don't have an authorId for whatever reasons. When you are trying to save such a single entry with an $authorId is removed in the beforeSave function

// Section type-specific stuff
if ($section->type == Section::TYPE_SINGLE) {
    $this->authorId = null;
    $this->expiryDate = null;
}

So far no problem, but when you send an ajax request the controller does the following

if ($request->getAcceptsJson()) { 
    ......
    $return['authorUsername'] = $entry->getAuthor()->username; /<--- you'll receive an exception here
}

Steps to reproduce

  1. Create a new section of type single in the CP, do something with the entry
  2. Try to save the entry via frontend ajax request

Steps to solve

change line 572 in EntriesController to

$return['authorUsername'] = $entry->getAuthor()? $entry->getAuthor()->username : '';

Additional info

  • Craft version: Craft CMS 3.0.0-RC17
brandonkelly added a commit that referenced this issue Apr 7, 2018
@brandonkelly
Copy link
Member

Fixed for the next Craft 2 and Craft 3 releases. Thanks!

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

2 participants