We propose a statistical field theory to study the properties of elastic rods confined in 2D containers. Using a mean-field evaluation of the path integral, we show how a self-reorganization of the folding pattern between disordered and ordered configurations above a critical density leads to a more efficient packing. In addition, we predict the existence of a jamming transition for higher densities. The nature of this jamming transition is compared with similar observations in experiments on packing of flexible structures. The advantage of this approach is that it puts on an equal footing the geometrical features (such as self-avoidance) and the mechanical response to confinement.