You want to delete the Type, not the SpecificType. You will also need to make sure you have your model set correctly for Type:
var $hasMany = array(
'SpecificType' => array(
'className' => 'SpecificType',
'foreignKey' => 'type_id',
'dependent'=> true,
)
);
Then delete the type and it will work.
If you are deleting the child (SpecificType
) and you want to delete it's parent, you must call the delete on the parent model. But keep in mind, if you have the Cascade set up correctly (dependent = true
on the model) all of the SpecificType
children will be deleted anyway.
Note: If you want to delete the parent of the child, you may want to reconsider your relationships and confirm they are correct. If that is really how you want them, then don't do the delete on the child. Simply make sure your cascade relationships are set correctly, pull the child's parent information, and delete the parent. Then all of the children will be removed as well.