You are not logged in.

Important Note: This forum is being archived and will be completely locked down on the 7th of February. The new forum can be found at


    Laravel 4 Advanced Architecture: Book Now On Sale

#1 2013-05-27 00:14:27

Registered: 2013-05-26
Posts: 3

Adding a style tag to a form input

Hello fellow Laravellers! I am on hour 12 at least since I just discovered this framework and have been playing with it non-stop. I am working to build a custom CRM style program which leverages Laravel and Bootstrap from Twitter.

I've been on tutorials all day and finally got a little to show for it! (A login, logout system and a dashboard page). It's all very exciting!

Well now I've run into a tiny issue, and maybe the answer is just "it isn't possible" because I have followed the documentation and can't get it working. I am trying to get a class to show on one of my forms inputs like so:

<?php echo Form::email('email', array('class'=>'awesome')); ?>

This works on buttons and on the form open tag itself, but I need to make the input itself have a class like so when printed out:

<input type="email" name="email" class="awesome">

However, I can't get it to work, and whenever I put that code in I get:

Unhandled Exception


htmlentities() expects parameter 1 to be string, array given

-snip-\ss\laravel\html.php on line 41
Stack Trace:

#0 -snip-\ss\laravel\laravel.php(42): Laravel\Error::native(2, 'htmlentities() ...', 'C:\Program File...', 41)
#1 [internal function]: Laravel\{closure}(2, 'htmlentities() ...', 'C:\Program File...', 41, Array)
#2 -snip-\ss\laravel\html.php(41): htmlentities(Array, 3, 'UTF-8', false)
#3 -snip-\ss\laravel\html.php(414): Laravel\HTML::entities(Array)
#4 -snip-\ss\laravel\form.php(223): Laravel\HTML::attributes(Array)
#5 -snip-\ss\laravel\form.php(287): Laravel\Form::input('email', 'email', Array, Array)
#6 -snip-\ss\laravel\view.php(386) : eval()'d code(49): Laravel\Form::email('email', Array)
#7 -snip-\ss\laravel\view.php(386): eval()
#8 -snip-\ss\laravel\view.php(353): Laravel\View->get()
#9 -snip-\ss\application\controllers\users.php(37): Laravel\View->render()
#10 [internal function]: Users_Controller->get_dashboard()
#11 -snip-\ss\laravel\routing\controller.php(325): call_user_func_array(Array, Array)
#12 -snip-\ss\laravel\routing\controller.php(285): Laravel\Routing\Controller->response('dashboard', Array)
#13 -snip-\ss\laravel\routing\controller.php(165): Laravel\Routing\Controller->execute('dashboard', Array)
#14 -snip-\ss\laravel\routing\route.php(153): Laravel\Routing\Controller::call('users@dashboard', Array)
#15 -snip-\ss\laravel\routing\route.php(124): Laravel\Routing\Route->response()
#16 -snip-\ss\laravel\laravel.php(167): Laravel\Routing\Route->call()
#17 -snip-\ss\public\index.php(34): require('-snip-...')
#18 {main}

Has anyone been able to get classes to work on form inputs? Or am I going about it the wrong way?

I am using Laravel 3, only because all the Github and command line stuff freaked me out and I couldn't get it to work quickly to try Laravel 4.
I am not using Blade template engine in case that matters.

Thank you for any help - I'm sure it won't be my last post here! smile


#2 2013-05-27 05:36:32

From: Sri lanka
Registered: 2013-01-28
Posts: 51

Re: Adding a style tag to a form input

First of all welcome smile

I just took a quick look at Form API an saw Form::email() method take 03 parameters.

Form::email( string $name, string $value = null, array $attributes = array() )

So can you see the issue? smile

Always try to use the API documentation. It contains more details in depth than general docs.


#3 2013-05-27 13:17:41

From: Europe
Registered: 2013-04-10
Posts: 138

Re: Adding a style tag to a form input

Or dig into the code big_smile Since I use PHPStorm with an IDE helper all I have to to is: Mark a Laravel method name and press CRTL+Q to get parameters information. I don't use the API docs.


#4 2013-05-27 17:13:33

Registered: 2013-05-26
Posts: 3

Re: Adding a style tag to a form input

Wow! It worked smile Thanks a lot! And thank you for that link, I didn't even see that link before.

My follow-up questions was going to be if it stopped then taking the forms value because it was set to null but it didn't mess that up at all! For anyone else, here is my code:

             <div class="control-group">
				<?php echo Form::label('email', 'E-Mail Address', array('class'=>'control-label'));
                    echo Form::text('email', '', array('class'=>'input-small')); ?>

I don't fully understand "Git" or "Composer" or all of those fancy tools. I have Cygwin installed but I don't know how to use it. I've been using Dreamweaver since I have it for work as my IDE but it is a bit lacking... I will check out PHPStorm when I get stuck again (bound to happen) I haven't had this much fun coding in a long time! Although I still feel like I have no idea what I'm doing...

Thanks for the help!


#5 2013-05-27 17:50:58

Registered: 2013-04-01
Posts: 6

Re: Adding a style tag to a form input

Welcome to the forum

it is because you gave the second parameter array, if you want it to work, the second parameter is the input value, just leave it empty with quotes like so

<?php echo Form::email('email', '', array('class'=>'awesome')); ?>


Board footer

Powered by FluxBB