Ich versuche, eine before Funktion zu implementieren, dass von einem ausgewählten modal Dropdown dementsprechend Wert auf positive oder negative Zahl ändert sich, aber es ist immer entsprechend der ersten ändern, wenn:yii2 before mit modalen Dropdownlist
ist dies die modal Code:
<?= $form->field($model, 'tipo_fatura')->dropDownList([ 'Fatura' =>
'Fatura', 'Nota de Crédito' => 'Nota de Crédito', ],
['prompt' => '']) ?>
und das ist der Modellcode:
public function beforeSave($insert)
{
if (!parent::beforeSave($insert)) {
return false;
}
$tipo_fatura = $this->tipo_fatura;
if ($tipo_fatura->index = 2) {
$this->valor_fatura = 2;
} else if ($tipo_fatura = 'Fatura') {
$this->valor_fatura = 1;
} else {
}
return true;
}
Sorry, über mein schlechtes Englisch.
Und danke im Voraus.
Ich kann nicht glauben, dass ich so dumm war, D, Manny danke. – Motorui