We study the Friedman-Robertson-Walker model with phantom fields modeled in terms of scalar fields. We apply the Ziglin theory of integrability and find that the flat model is nonintegrable. Then we cannot expect to determine simple analytical solutions of the Einstein equations. We demonstrate that there is only a discrete set of parameters where this model is integrable. For comparison we describe the phantoms fields in terms of the barotropic equation of state. It is shown that in contrast to the phantoms modeled as scalar fields, the dynamics is always integrable and phase portraits are contracted. In this case we find the duality relation.