0
Ich benutze Yii2 als mein Framework in PHP-Entwicklung, in meiner ticket.php die "time_end" wird automatisch die Computerzeit bekommen, wenn eine bestimmte Daten in ticket.php geht Mein Problem wird aktualisiert, wenn es aktualisiert wird, wird es nicht angezeigt. Er sagt (nicht-Set)Aktualisierter Wert im Formular wird nicht angezeigt
Mein TicketController.php
public function actionCreate()
{
$model = new Ticket();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->time_start = date('d-m-y h:i:s');
return $this->render('create', [
'model' => $model,
]);
}
}
/**
* Updates an existing Ticket model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param integer $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
$model->time_end = date('d-m-y h:i:s');
return $this->render('update', [
'model' => $model,
]);
}
}
Mein _form.php
<?= $form->field($model, 'time_end')->widget(DateTimePicker::className(),
[
'value' => date('d-m-y h:i:s'),
'disabled' => true
]
); ?>
Die view.php
<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\Ticket */
$this->title = $model->id;
$this->params['breadcrumbs'][] = ['label' => 'Tickets', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="ticket-view">
<h1><?= Html::encode($this->title) ?></h1>
<p>
<?= Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']) ?>
<?= Html::a('Delete', ['delete', 'id' => $model->id], [
'class' => 'btn btn-danger',
'data' => [
'confirm' => 'Are you sure you want to delete this item?',
'method' => 'post',
],
]) ?>
</p>
ich die var_dump verwendet, und es zeigt die Systemzeit, habe ich die view.php – noobkoder
Ich fand bereits eine Art und Weise bei der Festsetzung der „nicht festgelegt“, aber wenn ich das Formular aktualisieren aktualisiert sie beide time_start und time_end – noobkoder