Is "Wir gaben einen Ball dem Elephanten" correct?
Usually if you use nouns, the indirect object stands before the direct object: Wir gaben dem Elefanten einen Ball.
Why is "Wir haben einen Ball dem Elefant gegeben" not correct?
As said above, you would normally put the indirect object in front of the direct object, but also Elefant is a weak noun and needs to be "dem ElefantEN".