InvalidParameterException Entity type must be set.

We get the above error messages when trying to save a newly created object.

In start.php we have:  

 

  // Register subtype

  add_subtype("object", "jobs");

And in the action/add.php we have:

 

  $job = new ElggObject();

  $job->subtype = "jobs";

  if($job->save()){

//ok

  } else {

register_error(elgg_echo("jobs:add:error:save"));

  }

So, the code never reaches the "//ok"  as it trows the InvalidParameterException, Entity type must be set when it tries to save() ... 

All seems so obvious... what do we do wrong here??  The other plugins and save() actions on new objects work perfectly...

  • oh... help please.... looking at this for hours now... What am I missing here?

  • try adding

    register_entity_type('object', 'jobs');

    in your start.php

  • If the code is logged out you'll need to use elgg_set_ignore_access(TRUE) before trying to save.

  • Oh, for some strange reason, my own solution I posted here by editing my second comment, did not show up...

    So, I try again. Found it myself: I made a stupid mistake, simply one of my own parameters I used was:   $job->type 

    So obvious and stupid of course! Renaming that parameter to $job->job_type and all works fine ;))))))))))))) , I should not have touched it. Thanks for the replies! A little more work and we will submit this jobs = submit vacanies plugin to the community ;)