Skip to content

Instantly share code, notes, and snippets.

<?= Html::a('Löschen', ['delete', 'id'=>$model->id], [
'data' => [
'confirm' => "Bist du sicher?",
'method' => 'post',
],
]); ?>
$heute = \date("Y-m-d H:i:s");
$datetime1 = date_create($date);
$datetime2 = date_create($heute);
$interval = date_diff($datetime1, $datetime2);
return $interval->format('%R%a Tage');
$heute = date("Y-m-d H:i:s");
$dteStart = new DateTime($heute);
#### View #####
<div class="row">
<div class="col-lg-1">
<i class="like fa fa-fw fa-heart" data-warrior= <?= $model->id ?>></i>
</div>
<div class="col-lg-1">
<div id=<?= $model->id ?>> <?= $model->like ?> </div>
</div>
</div>
@beatcode
beatcode / _form.php
Created June 11, 2015 08:40
Yii2 onchange Ajax Event
<?= $form->field($model, 'IDProdukt')->dropDownList(ArrayHelper::map(TblProdukte::find()->all(), 'ID', 'Produkt'),
['prompt' => '-Produkt wählen-',
'onchange' => '
$.get( "index.php?r=buchung/getprice&id="+$(this).val(), function( data ) {
$( "#tblbuchung-preis" ).val( data );
});
']); ?>
@beatcode
beatcode / index.php
Created June 10, 2015 12:11
Yii2 GridView Image
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
[
'label'=>'Image',
'format'=>'raw',
'value' => function($data){
@beatcode
beatcode / index.php
Created June 10, 2015 12:08
Yii Gridview Datum Format
[
'attribute'=>'Datum',
'label'=>'Termin',
/*'format'=>'date',//date,datetime, time*/
'format' => ['date', 'php:d.m.Y'],
'headerOptions' => ['width' => '130'],
],
public function successCallback($client)
{
$attributes = $client->getUserAttributes();
if (isset($attributes) && isset($attributes['email'])) {
$login = new LoginForm();
$login->username = $attributes['email'];
$login->password = $attributes['email'];
@beatcode
beatcode / GridView Action Column
Created January 9, 2015 20:54
GridView Action Column
['class' => 'yii\grid\ActionColumn',
'template' => '{info}{view}',
'buttons' => [
'info' => function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-envelope"></span>', $url, [
'title' => Yii::t('app', 'Antworten'),
]);
}
],
'urlCreator' => function ($action, $model, $key, $index) {
@beatcode
beatcode / Yii2 Google OpenId SuccessCallback
Last active August 29, 2015 14:12
Yii2 Google OpenId SuccessCallback
public function successCallback($client)
{
$attributes = $client->getUserAttributes();
if (isset($attributes)) {
$login = new LoginForm();
$login->username = $attributes['contact/email'];
$login->password = $attributes['contact/email'];
@beatcode
beatcode / Index.php
Created December 30, 2014 21:19
MetaDaten
<?php $this->registerMetaTag(['name' => $model->skill, 'content' => $model->beschreibung]); ?>