コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Customer::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'address', $this->address]);
     return $dataProvider;
 }
コード例 #2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCustomer()
 {
     return $this->hasOne(Customer::className(), ['id' => 'customer_id']);
 }
コード例 #3
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model romaten1\customer\models\CustomerOrder */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="customer-order-form">
    <div class="row">
        <div class="col-md-10">
    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'customer_id')->dropDownList(Customer::getCustomersArray(), ['prompt' => 'выберите покупателя ...']);
?>

    <?php 
echo $form->field($model, 'posted_at')->widget('trntv\\yii\\datetimepicker\\DatetimepickerWidget', ['phpDatetimeFormat' => 'dd-MM-yyyy', 'momentDatetimeFormat' => 'DD-MM-YYYY', 'clientOptions' => ['viewMode' => 'months', 'minDate' => new \yii\web\JsExpression('new Date("1970-01-01")'), 'sideBySide' => true, 'showClear' => true, 'widgetPositioning' => ['horizontal' => 'auto', 'vertical' => 'auto']]]);
?>

    <?php 
echo $form->field($model, 'amount')->textInput();
?>

    <?php 
echo $form->field($model, 'paid_at')->widget('trntv\\yii\\datetimepicker\\DatetimepickerWidget', ['phpDatetimeFormat' => 'dd-MM-yyyy', 'momentDatetimeFormat' => 'DD-MM-YYYY', 'clientOptions' => ['viewMode' => 'months', 'minDate' => new \yii\web\JsExpression('new Date("1970-01-01")'), 'sideBySide' => true, 'showClear' => true, 'widgetPositioning' => ['horizontal' => 'auto', 'vertical' => 'auto']]]);
?>

    <div class="form-group">
コード例 #4
0
 /**
  * Finds the Customer model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Customer the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Customer::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }