I have a function attached to a hook which should add a category
$category = new Category();
$category->name = 'foobar';
$category->active = true;
$category->id_parent = 2;
$category->level_depth = 2;
$category->add();
When I click the button, the function runs but returns this error
Property Category->name is empty.
I double-check by logging the value of $category->name before the add() call and it's correct.
Why would it give this error?