- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to make Laravel (Blade) text field read-only?
Blade is a template engine that helps you to build your view display in laravel. It also helps you to use php code inside the template.
The blade templates are saved as filename.blade.php and are stored inside resources/views/ folder. To understand the above question let us create a view calling the blade template.
Example 1
Inside routes/web.php I have created the following route that is calling the view hello with data ['mymsg' => 'Welcome to Tutorialspoint'].
Route::get('hello', function () { return view('hello', ['mymsg' => 'Welcome to Tutorialspoint']); });
The hello.blade.php is inside resources/views folder −
{{$mymsg}}
Output
The output when you test will be −
Welcome to Tutorialspoint
Example 2
Adding text field inside blade template
Now let us understand how to add text field and make it readonly.
<?php echo Form::open(array('url'=>'/hello')); echo Form::text('name'); echo Form::close(); ?>
Output
Now if you check, you will see a textbox as shown in the output −
Example 3
To make a text field as read-only you need to add the following code −
<?php echo Form::text('name',null, ['readonly']); ?>
The code inside hello.blade.php is as follows −
<?php echo Form::open(array('url'=>'/hello')); echo Form::text('name',null, ['readonly']); echo Form::close(); ?>
Output
Now when you check the output it will be as follows −
Example 4
you can also add the html input text with read-only attribute in blade template as shown below −
<?php echo Form::open(array('url'=>'/hello')); echo Form::text('name',null, ['readonly']); echo Form::close(); ?> <input readonly="readonly" name="username" type="text" value="readonly">
Output
The output of the above code is as follows −
- Related Articles
- How to make the Tkinter text widget read only?
- How to make Java ArrayList read only?
- How to Insert a value to a hidden input in Laravel Blade?
- How to make an ArrayList read only in Java?
- How to make a collection read only in java?
- Golang program to make a file read-only
- Make a Hashtable read-only in Java
- How to make a textarea and input type read only using jQuery?
- How to extract only the numbers from a text field in MySQL?
- How to read only 5 last line of the text file in PHP?
- Indexing large text field to make query faster in MongoDB
- How to validate aninput field if the value is not NULL in Laravel?
- How to add read-only property in C#?
- How to read a text file with C++?
- How to read a text file in Python?
