Laravel Classroom image

Prashant  Nigam / Student / Web Technology

 
To post your Question Join Classroom
 
Lesson Topics's No:-  First|1 | 2 | 3 | 4 | 5 | 6 | 7|Last
Lessons:-Forms

6.3 Generating Inputs
Next we have the input generators, these methods help to generate all of the HTML elements
that are common to forms. In the example above we use the text() and password() method to
generate <input type="text".. and <input type="password".. elements.The first parameter to the method, is the value of the elements name attribute. The optional
second parameter is the default value of the element. Once more we can pass an array of HTML
attributes as an optional third parameter. Are you starting to see a pattern yet?
The textarea() and hidden() methods also accept the same parameters as the text() method.
Check-boxes can be created using the checkbox() method, with the first parameter being the
name of the element and the second being the value. The third option is an optional boolean
switch to set whether the element is initially checked or not. It will default to false. The fourth
optional parameter again sets attributes. In fact, go ahead and assume that all future inputs
accept an attributes array as their optional final parameter. Let’s have a look at a check-box
generator..
1 <?php echo Form::checkbox('admin', 'yes', true, array('id' => 'admin-checke\
2 r')); ?>
The radio() method creates radio buttons and shares the same parameters as the checkbox()
method.
Next we have drop downs, the most awkward of all form elements. Fortunately, all we need
to do is pass a name, an array of value => label options, and an optional parameter to state
which option should be selected by default to the select() method. Our drop-down will then
be generated for us, for example..
1 <?php
2
3 Form::select('roles', array(
4 0 => 'User',
5 1 => 'Member',
6 2 => 'Editor',
7 3 => 'Administrator'
8 ), 2);
and we get..
1 <select name="roles">
2 <option value="0">User</option>
3 <option value="1">Member</option>
4 <option value="2" selected="selected">Editor</option>
5 <option value="3">Administrator</option>
6 </select>

 
 
 

Prashant  Nigam

Skills    Laravel

Qualifications :-
Location :-,,,
Description:-
Explore
 

  Students (0)