Automotive electronic circuit design, Voltage divider to uC ADC pin
I'd say a divider is not enough since from spec you need 5V when the battery is connected. Battery can go from about 8V to… nominal 18V but you need to protect for up to about 100V, in the worst case. There's an ISO with the required ''has to survive to'' signals. Your 32V maximum is probably referring to a jump start battery condition, IIRC it should be for not more than 60 seconds.
I would start with some appropriate TVS (there are parts specifically designed for load dump condition) to clamp to a sane level (usually about 30V, check the pass-thru rating of the diode). If you need a continuous 32V voltage, well, there are many ratings for these. A reverse protection diode (you don't want to source to the battery line) and at last a resistor-zener clamp to 5V and a pullup to 2.5V to handle the disconnected case. Spruce filter capacitors as needed since the battery line is hell.
Personally I would buffer the 2.5V and the output with a voltage follower to better isolate the circuit but it's not strictly necessary. That would also another good opportunity for filtering, if needed.
There is actually a case when this circuit would fail: during cold crank (starting the engine in winter) the battery line can (by spec) go down to about 4V, and this is the voltage you would have on your output line. It depends on your 'battery connected' definition and how much leeway on the output values you have.
Sadly this only works on low battery because of the diode leakage current. It's really not good practice. You could do a transistor contraption as an exercise but it will be difficult to reach the rails and have 'sharp' transitions. In 2020 we have better solution for these things (we actually have dedicated battery monitor ICs!)
In fact detecting the 'cable disconnected' situation is difficult in itself since any required protection or filter component will draw the signal toward one power rail (ground, usually). The same protection TVS, for an high impedance input, would be seen as a grounded line. I think the only way to do it is to try to force some small current out of it and see if it goes around to ground. This could be taken from the 5V rail since if it doesn't flow because there are 12V, well, you have 12V to see on the inputs. With some clever comparator positioning you could do it.
Definitely not simple, in my opinion. If there are definite battery thresholds, the usual way to do it is this:

Let's assume that 2-4V is forbidden and will be detected as disconnected.
Scale the battery down with the divider so that, say, 12V is 5V on the output
Add a pullup to some reference voltage the battery can't have so that with the battery disconnected the voltage is 3V. This is where the network resistor exercises come to fruition!
Zener it to 5V (4.7V, actually, is the nearest standard zener). Be careful to have enough zener current to make it work
On the output place two comparators that pull up when the voltage is over 4V and pull down when the voltage is below 2V.

This is more or less what I would make:

Comparators must have push-pull outputs to work, it's a common variation on the window comparator (maybe there's an integrated version of it)
This has of course drawbacks on the original specs:

There is a battery voltage range which is detected as disconnected;
Output is not 0V and 5V but about 0.3V and 4.7V (a diode loss); this is not perfect but remains easily detectable.