This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
I want to call a function which I was create in Model, into List - Partial. So is there have anyway to call function like this? Thanks
Hi phamvuduycuong15027,
That sounds not the right way. You want to call a function to get some data? Than please call your function from controller and pass the data to your view/partial. If you want to make a POST Request a controller has to respond to this. In Controller method surly you can call a method in your model. If you dont like the page reload please check http://octobercms.com/docs/cms/ajax for ajax Calls.
Regards Crazymodder
Even though you shouldn't be doing that, as @Crazymodder said, since views should only contain view logic (the most should actually be if``s,
for```s and stuff like that) you can call any model function in your view just as you want.
Imagine a model has a method convertToBar
and that model is in the view with name foo
you can do
{% set bar = foo.convertToBar %}
works with or without the parentheses.
But again, views should only contain view logic, every data processing and preparing should be done in our controller or model.
Last updated
any solution for this problem.. I have the same problem, i want to call a member function in my view.. Help please
1-5 of 5