A generalization of the Buckdahn-Föllmer formula is obtained by considering a composite transformation $\xi (x, F(x))$ in the framework of the Ramer-Kusuoka formula where $F(x)$ takes values in a finite dimensional space. The point is to establish the chain rule for composite Wiener functionals through the continuity of the substitution. The localization argument makes it possible to deal in our framework with the transformations studied by C. Donati-Martin, H. Matsumoto and M. Yor [5]. Our formula gives a new approach to the study of quadratic Wiener functionals.