camel case function is not found

I am creating a yii2 form to add a new product in the index.php (above gridview). I make the call using ajax. The url is set to


    function submitProduct() {


            type: 'POST',

            url: "<?= Yii::$app->getUrlManager()->createUrl('/product/addProduct') ?>",

            data: $('#add-product-form').serialize(),

            success: formProductSaved,

            dataType: 'json'




While inside the ProductController.php


   public function actionAddproduct() {

        if (Yii::$app->request->isPost) {

            $model = new Product;

            if ($model->load(Yii::$app->request->post()) && $model->save()) {

                return Json::encode(array(

                            'status' => 'success',

                            'title' => 'Add produdct',

                            'message' => 'Product is added successfully.',


            } else {

                $errors = array_map(function($v) {

                    return join(', ', $v);

                }, $model->getErrors());

                return Json::encode(array('status' => 'error', 'title' => 'Add product', 'message' => "Errors: " . implode(" ", $errors)));


        } else {

            throw new HttpException(400, 'Invalid request');




Strangely enough, if I change the function to addproduct, it will work flawlessly. Can someone help to explain about this?

Thank you.


i commented on your other post

but it would be


because camel cased controller actions are set in the base/controller createAction() to do so