How to Insert a value to hidden input Laravel Blade

0 votes

How to pass a value to hidden input ?

Create form :

@if (isset($id))
    {!! Form::hidden('edition', $id) !!}
@endif

I got the form id by url like this :

<a href="../journal/create?edition={{$edition->id}}" class="btn btn-primary">Add Journal</a>

( when I click Add Journal button it will shows a create form with edition id at the url)

and the controller is :

$id = $request->get('edition');
        $journal = Edition::findOrFail($id)->journal()->create($input);

The result gave me this error "No query results for model [App\Edition]."

Dec 1, 2020 in Laravel by kartik
• 37,520 points
12,851 views

1 answer to this question.

0 votes

Hello @kartik,

Usually, this is used in Blade templates.

Just pass the name and value to the method.

{{ Form::hidden('invisible', 'secret') }}

This creates a very simple element which looks like the following.

<input name="invisible" type="hidden" value="secret">

To add other attributes, pass a third argument to the method. This third argument must be an array.

{{ Form::hidden('invisible', 'secret', array('id' => 'invisible_id')) }}

Now the input has an id attribute.

<input id="invisible_id" name="invisible" type="hidden" value="secret">
answered Dec 1, 2020 by Niroj
• 82,840 points

Related Questions In Laravel

0 votes
1 answer

How to break a for each loop in laravel blade view?

Hello @kartik, By default, blade doesn't have @break and @continue which are ...READ MORE

answered Apr 6, 2020 in Laravel by Niroj
• 82,840 points
13,442 views
+1 vote
1 answer

How to load blade or php content into a view via ajax/jquery in laravel?

Hello @kartik, Assuming you're using jQuery... create a route ...READ MORE

answered Apr 14, 2020 in Laravel by Niroj
• 82,840 points
28,030 views
0 votes
1 answer

How to change value of a request parameter in laravel?

Hello @kartik, Use merge(): $request->merge([ 'user_id' => ...READ MORE

answered Aug 10, 2020 in Laravel by Niroj
• 82,840 points
16,685 views
0 votes
1 answer

How to validate an input field if value is not null in Laravel?

Hello @kartik, try using nullable as a rule 'password' ...READ MORE

answered Sep 25, 2020 in Laravel by Niroj
• 82,840 points
15,982 views
0 votes
1 answer

jQuery AJAX fires error callback on window unload - how do I filter out unload and only catch real errors?

Hello, In the error callback or $.ajax you have three ...READ MORE

answered Apr 27, 2020 in Java-Script by Niroj
• 82,840 points
4,228 views
0 votes
1 answer

How do I pass command line arguments to a Node.js program?

Hello @kartik, If your script is called myScript.js ...READ MORE

answered May 5, 2020 in Java-Script by Niroj
• 82,840 points
3,274 views
0 votes
1 answer

Error:Issue when trying to use IN() in wordpress database

Hello @kartik, Try this code : // Create an ...READ MORE

answered May 8, 2020 in PHP by Niroj
• 82,840 points
1,147 views
+2 votes
1 answer

How do I debug Node.js applications?

Hello @kartik, Use node-inspector  from any browser supporting WebSocket. Breakpoints, ...READ MORE

answered Jul 8, 2020 in Node-js by Niroj
• 82,840 points
1,044 views
0 votes
1 answer

How to include a sub-view in Blade templates in Laravel?

Hello @kartik, You can use the blade template ...READ MORE

answered Mar 31, 2020 in Laravel by Niroj
• 82,840 points
15,229 views
0 votes
1 answer

How Can I Set the Default Value of a Timestamp Column to the Current Timestamp with Laravel Migrations?

Hello, To create both of the created_at and updated_at columns: $t->timestamp('created_at')->default(DB::raw('CURRENT_TIMESTAMP')); $t->timestamp('updated_at')->default(DB::raw('CURRENT_TIMESTAMP on update ...READ MORE

answered Apr 2, 2020 in Laravel by Niroj
• 82,840 points
12,133 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP