Skip to content

Html Tags

emretulek edited this page May 20, 2020 · 7 revisions

Html etikleri oluşturmanıza yardımcı olur. Tag::class sınıfnın tüm methadlarını kullanabilirsiniz.

Html::tag

Html::tag(string $tagName, string $text = null)

echo Html::tag('h1', 'text');

Html Çıktısı

<h1>text</h1>

echo Html::tag('div', 'text')
    ->addClass("wrapper")
    ->attr('id', 'id1');

Html Çıktısı

<div class="wrapper" id="id1">text</div>

Html::input

input(string $type, string $name, string $value = null)

echo Html::input("text", "Ad Soyad")->addClass('form-control');

Html Çıktısı

<input type="text" name="Ad Soyad" class="form-control"/>

Html::file

file(string $name, $multiple = false)

echo Html::file("file", true)->attr("accept", "image/*");

Html Çıktısı

<input type="file" name="file[]" multiple="multiple" accept="image/*"/>

Html::select

Html::select(string $name, array $options, string $selectedOption = null, $multiple = false)

$countries = [
    "turkey" => "Türkiye",
    "usa" => "ABD",
    "italy" => "İtalya",
    "Asya" => [ // optgroup
        "Chine" => "Çin",
        'Iraq' => "Irak"
    ]
];

echo Html::select("countries", $countries, 'usa');

Html Çıktısı

<select name="countries">
  <option value="turkey">Türkiye</option>
  <option value="usa" selected="selected">ABD</option>
  <option value="italy">İtalya</option>
  <optgroup label="Asya">
    <option value="Chine">Çin</option>
    <option value="Iraq">Irak</option>
  </optgroup>
</select>

Html::checkbox

Html::checkbox(string $name, string $value = null, $checked = false)

$checkedValue = "2";

echo Html::checkbox("checkbox1", "1", $checkedValue);
echo Html::checkbox("checkbox1", "2", $checkedValue);
echo Html::checkbox("checkbox1", "3", $checkedValue);
echo Html::checkbox("checkbox1", "4", $checkedValue);

Html Çıktısı

<input type="checkbox" name="checkbox1" value="1"/>
<input type="checkbox" name="checkbox1" value="2" checked="checked"/>
<input type="checkbox" name="checkbox1" value="3"/>
<input type="checkbox" name="checkbox1" value="4"/>

Html::radio

Html::radio(string $name, string $value = null, $checked = false) Html::checkbox

Html::a

Html::a(string $href, string $text, string $target = null)

echo Html::a("http://github.com", "Git hub");

Html Çıktısı

<a href="http://github.com">Git hub</a>

Html::img

Html::img(string $src, string $alt = "")

echo Html::img("http://github.com/image.jpg", "Git hub");

Html Çıktısı

<img alt="Git hub" src="http://github.com/image.jpg"/>

Html::picture

Html::picture(string $src, string $alt, array $datasets = [])

$dataset = [
    'min-width:600px' => 'image2.jpg',
    'min-width:1200px' => 'image3.jpg'
];

echo Html::picture("http://github.com/image1.jpg", "Git Hub", $dataset);

Html Çıktısı

<picture >
<source media="(min-width:600px)" srcset="image2.jpg"/>
<source media="(min-width:1200px)" srcset="image3.jpg"/>
<img alt="Git Hub" src="http://github.com/image1.jpg"/>
</picture>

Tag::append, Tag::prepend örnek

echo Html::tag("label", "Label Text: ")
    ->append(Html::checkbox("checkboxname", "checkboxvalue", true));

echo Html::tag("label", " Label Text")
    ->prepend(Html::checkbox("checkboxname", "checkboxvalue", true));
<label >Label Text: <input type="checkbox" name="checkboxname" value="checkboxvalue" checked="checked"/></label>
<label ><input type="checkbox" name="checkboxname" value="checkboxvalue" checked="checked"/> Label Text</label>

Yardımcı Tag methodları:

Tag::text(string $text = null)
Tag::html(string $html = null)
Tag::val(string $value = null)
Tag::attr($attributes, string $value = null)
Tag::addClass(string $className)
Tag::removeClass(string $className)
Tag::removeAttr($attributes)
Tag::append(string $html)
Tag::prepend(string $html)
Tag::remove()
Clone this wiki locally