Elsa was holding his hand tight as she slept and soon the full moon was shining down on her and some of her energy she had went into him. So when he dreamed she was there and she has no knowledge that this happened for it mainly happened on the full moon when the light hit her and when she was near someone like she was now with Cody. If someone knew about this they would probably say it was because of the full moon and Elsa having some of the moon spirit in her.