How to enter a varibale in a name attribute in a form collective input?

1

I have a laravel blade form, using the input of the laravel collective form, for example:

    <div class="form-group col-xs-4">
        {!!Form::label('Titulo de modalidad','Titulo de modalidad:')!!}
        {!!Form::text("cancion5","value",['class'=>'form-control', 'placeholder'=>'Ingrese el titulo de la modalidad'])!!}
    </div>

I have a variable that contains a number:

{{$num = 1+4}}

I would like to insert that variable in the name attribute, I was thinking something like this:

    <div class="form-group col-xs-4">
        {!!Form::label('Titulo de modalidad','Titulo de modalidad:')!!}
        {!!Form::text("cancion{{$num}}","value",['class'=>'form-control', 'placeholder'=>'Ingrese el titulo de la modalidad'])!!}
    </div>

But it does not work for me, any way so I can insert the number 5 by a variable to the name?

    
asked by Susje 20.10.2017 в 05:34
source

1 answer

1

When you use the Blade syntax it's like you're doing an echo, then:

We can say that {{ $bla }} is almost the same as echo $bla , although Laravel applies certain filters to "clean" or "escape" the data.

When you use {!! $bla !!} , you are simply doing the same echo but without "cleaning" the data.

Now, in this case you are simply calling a method of a class by means of the Facade Form, punctually the text() method, for which you simply pass the variable as if it were pure PHP:

{!!Form::text('cancion'.$num, "value", ['class'=>'form-control', 'placeholder'=>'Ingrese el titulo de la modalidad'])!!}
    
answered by 20.10.2017 / 05:40
source