H
H
hollanditkzn2017-10-12 11:38:41
Yii
hollanditkzn, 2017-10-12 11:38:41

What is the best way to send data?

I have such a problem that the error Outputs Setting unknown property: app\models\Financy::2900
At my address http://crm/personnel/calculate?id=1∑=2900&wage=380...
In views

<?= Html::a('Расчитать', ['calculate', 'id' => $modelPersonnel->id, 'sum' => round($sumWage,2), 'wage' => round($wage,2), 'name' => $modelPersonnel->nameSotrud], ['class' => 'btn btn-primary']) ?>

In the controller
public function actionCalculate($id, $sum, $wage, $name)
    {
        $model = new Payroll();
        $financy = new Financy();
        $financy->scenario = 'employee';

        /** Payroll models */
        $model->personnel_id = $id;
        $model->sum = $sum-$wage;

        /** Financ models */
        $financy->$sum = $sum;
        $financy->id_employee = $id;
        $financy->category = Financy::SALARY;
        $financy->comment = 'Расчет зарплаты '.$name;

        $financy->save();
        $model->save();

        Yii::$app->session->addFlash('update', 'Произведен расчет '.$model->sum);
        return $this->redirect(['view', 'id' => $id]);
    }

In the model of which the error is displayed by the following structure
public function rules()
    {
        return [
            [['sum'], 'required', 'on' => 'default'],
            [['category', 'sum', 'comment'], 'required', 'on' => 'employee'],
            [['id_zakaz', 'id_user', 'id_employee', 'category'], 'integer'],
            [['date'], 'safe'],
            ['sum', 'filter', 'filter' => function($value){
                return str_replace(' ', '', $value);
            }],
            [['comment'], 'string'],
            ['sum', 'compare', 'compareValue' => $this->amount, 'operator' => '<=', 'type' => 'number', 'on' => 'default'],
            [['id_user'], 'exist', 'skipOnError' => true, 'targetClass' => User::className(), 'targetAttribute' => ['id_user' => 'id']],
            [['id_zakaz'], 'exist', 'skipOnError' => true, 'targetClass' => Zakaz::className(), 'targetAttribute' => ['id_zakaz' => 'id_zakaz']],
        ];
    }

Or is it better to send the data in a hidden form?

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
M
Maxim Fedorov, 2017-10-12
@hollanditkzn

Yes, please read the error.
What is he talking about? about trying to set an unknown class attribute to 2900 class line app\models\Financy. What does that mean? that either you are accessing a non-existing property, or you are not working with an object

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question