Closed dcarrith closed 11 years ago
It turns out that the $recaptcha_lang variable was null. After I set it, the Array to string conversion error went away. Since I'm porting an existing application from CodeIgniter, I could have sworn that variable WAS defined. I guess I deleted too much stuff from the controller while migrating that file to Laravel. I'll close the issue since it was user error.
I'm using a custom reCAPTCHA widget and want to pass in the language that's currently in use. I have a view which defines a blade section and then yields it in a layout. When I try to use a variable inside of JSON which is inside of a script tag, I get a nasty Array to string conversion error.
@section('content')
<script type="text/javascript" charset="utf-8"> var RecaptchaOptions = { theme: "custom", lang: "{{ $recaptcha_lang }}" }; custom_theme_widget: "recaptcha_widget" </script> ... @stop
Taking the variable out gets rid of the error:
@section('content')
<script type="text/javascript" charset="utf-8"> var RecaptchaOptions = { theme: "custom", lang: "english" }; custom_theme_widget: "recaptcha_widget" </script> ... @stop
Here's the stack trace:
ErrorException: Notice: Array to string conversion in /var/www/musxc.com/htdocs/app/storage/views/a19f020bba55806642b788a150d9a773 line 5