Mich, the blue Carlon boxes with the metal bracket on the side are made to attach to steel or wood studs. You'll need a couple of sheet-metal or drywall screws for secure attachment.
You could also attach regular nail-on boxes to 1' pieces of 2x4, and then screw them to the studs, again with sheet-metal or drywall screws through the metal and into the wood.
The 1' of wood will give you room for a cable staple. Beyond the wood, you should secure the cable with wire-ties that hace screw-eyes and the afore-mentioned screws, or self-adhesive ones.
If the cable rund through holes in the metal, they must be protected with plastic "grommets" made for the purpose, and properly attached. Flex-enclosed cables don't require this protection.