Updating the dropdown list field value which is created using drop down list using create

StackOverflow https://stackoverflow.com/questions/13683587

  •  04-12-2021
  •  | 
  •  

Pergunta

i got a problem while updating a record for a model in yii. i have 2 models. im working on one model now. I'm creating a record for one model using create controller. in the form i've 1 fields which is the name field(im getting this name from other model(table). im getting the names from this second table and showing them in dropdown list. and storing them.

when it comes to update its again coming up with the same dropdown what i've shown using the _form.php for creating a record. can anyone pls tell me how can i show the name instead of dropdown list again??

thanks in advance.

Foi útil?

Solução

Add a simple check in your view to see if the value has already been added or not. Something like this:

<?php if ($model->attribute && $model->attribute != ''): ?>
    // Code to display a normal textfield here
<?php else: ?>
    // Code to display dropdown
<?php endif; ?>
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top