php - Is it right to call a component function or its output in view form in yii2?
I am stuck in a situation where I am trying to get the output of a component to be shown in the view form as a dropdown. I cannot use model to store the data from the component output and show it in the view. As that will result in a huge data storage and might slow the application processing. The only option left is to directly use this component output in view.
Now, I am confused if I should call this output in controller and from controller I call the controller method in view similar to this: http://www.yiiframework.com/forum/index.php/topic/63169-way-to-call-controller-method-in-view-yii2/
The other way is to use JS in frontend and use the component output shown there in the view. Not sure if this is a good way either. What will be the right way to do this?
Answer
Solution:
You can use Component result in your view.
I am giving you an exapmle to get country code from component and store it in Model.
Ex.Function in Component.
Function used in view for DropDown List