Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7052527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:23:40+00:00 2026-05-28T03:23:40+00:00

In my Yii application I have a pretty simple model setup. I’ve used the

  • 0

In my Yii application I have a pretty simple model setup. I’ve used the gii autogenerated code to create the basic CRUD, while I get the data for my app in place.

So, I have Authors, and Books. A Book belongs_to an Author.

I have a huge list of books already to enter – but as I haven’t entered the Authors yet – none of my books will save, as I keep getting “Trying to get property of non-object” when I save without selecting an author- despite not making Author “required”.

As I haven’t got my list of books organised by author (it’s a straight list of titles in a CSV list) this is preventing me saving any Books.

How can I make the Author optional?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T03:23:40+00:00Added an answer on May 28, 2026 at 3:23 am

    So the answer was more simple than I realised – I had the wrong relationship. Instead of a “belongs to” I needed a “has one”. The has one relationship allows for nulls.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code in my model for Application, I'm trying to get all
I am using YII framework for my web application . I have a question
In my application , I have ApiController with actionUsers , So in YII the
I am implementing facebook registration in my Yii site.. I setup application. For registration,
I have made an application in Yii. Now as per my application requirement I
I'm creating a test application with Yii and have created my first migration. <?php
In my application, i have fields that are common to all tables, like create
When I create a new Yii application using the yii webapp [my_application] command, it
I am trying to add OpenSearch functionality to my Yii application and have trouble
I am running a PHP/Yii application on Apache. I have tried doing the following:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.