Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide label for input field

I am trying to hide the label for a specific field in _form.php without success.

I have tried couple of variation like, but none is working:

<?= $form->field($model, 'sample_text')->textArea('label'=>false) ?> 

and alternate code:

<?= $form->field($model, 'sample_text')->textArea('label'=>'') ?> 

What is the right approach to hide a label?

like image 819
Joshi Avatar asked Nov 19 '14 12:11

Joshi


People also ask

How do you hide a label?

The hidden attribute hides the <label> element. You can specify either 'hidden' (without value) or 'hidden="hidden"'. Both are valid. A hidden <label> element is not visible, but it maintains its position on the page.

How do you hide a label in gravity form?

Go to Customize menu and then click on 'Styles & Layouts GF Forms'. You now need to select the form for which you want to hide labels and sub-labels. After selecting form you will see plenty of design controls. Open the Field Labels section and then click on 'Hide Labels' setting.


2 Answers

Ok, I found the solution.

<?= $form->field($model, 'sample_text')->textArea()->label(false) ?> 
like image 121
Joshi Avatar answered Oct 08 '22 20:10

Joshi


Or you can modify template value for particular field and remove {label} part from it. I.e.:

<p><?= $form->field($page, 'image', [     'template' => '<div class=\"\">{input}</div><div class=\"\">{error}</div>' ])->fileInput() ?></p> 
like image 20
trejder Avatar answered Oct 08 '22 21:10

trejder