If I have a URL like https://example.com/controller/action?customer-id=7414 how do I get customer-id in my action parameters? Since a dash is not allowed in variables names I cannot do the following! Documentation is usually excellent but on this exact point it’s just silent. How do I solve this? Answer When yiiwebController calls action it only binds parameters which names match exactly.
Tag: yii
Yiimp: CDbException: CDbConnection failed to open the DB connection. error when hasGetInfo is set to false
I’m getting the CDbConnection failed to open the DB connection error. The thing is, my database connection seems to be okay, as evident from the fact that the YIIMP logs display the retrieved values that I print out (see the text in the yiimp-logs/debug.log). I haven’t modified the YIIMP source codes besides adding the debuglog lines. I’m running the server
Is there a way to make a sidebar with the default Bootstrap 4 widget Yii2
I want to know if there is a way to make a sidebar with Bootstrap 4 default NavBar widget Answer https://github.com/kartik-v/yii2-widget-sidenav Helped me for this one, realy usefull.
How to change dateformat on Yii platform?
I am new to the Yii platform, and I am wondering how to change the dateformat. It’s currently in the American date format that is YYYY-MM-DD. I want it to be DD-MM-YYYY. Is there any way to this? Answer config file add in ‘components’ => [] You can add it and edit it to your style.
copy() fail to copy image from url to directory
I’m trying to copy an image from a URL to my server, but it doesn’t save. Below is my code The image URL in $url, doesn’t have a file extension, but the image is a .jpeg i tried both copy() and move_uploaded_file() but failed. when i use copy() i get this error I also tried with directory 2018/jeep/grand-cherokee exist and
Change status code in HTTP header without affecting return data in Yii 1 Restful API
I want to return data with the HTTP error code in Yii 1. So I used the following way to get the data. When I use it this way API returns data with 200 error code as below But I want to change header status 200, so I threw exception for this, then output data also changed. I want to
How to change font color on an ajax button? Php and Yii 1.1
I have a small question some of you might help me with instantly. I am currently working on a website where all the buttons need to be the same color. However, through some dumb reasons (lack of …
Yii2 Migration move data to other table
I have table: and I have created table I want to move some data(date_used & used_by_user_id) from table ticket to other table used with migration yii2 in the query. But I don’t know how to do it without ActiveRecord & array. Answer Only sql. Yii-migration not supported select in the insert into
Set reason for thrown bad request in Yii 2
I’m writing an API and I have to throw HTTP 400 bad request like below and it works fine meaning that it displays the default HTTP 400 page (I have no views defined because I’m building an API) What I would like to achieve is to give some reason for the bad request error thrown so that who is using
Yii2 Migration error – Unknown command: migratecreate Did you mean “migrate/create”?
I am learning database migration in Yii2. I am trying to create a new migration class create_news_table using command through composer. I installed composer globally and running command yii migrate/…