- Posts: 4
- Thank you received: 0
Welcome to the LimeSurvey Community Forum
Ask the community, share ideas, and connect with other LimeSurvey users!
Include Yii::app in custom file
- marmo91
- Topic Author
- Offline
- New Member
Less
More
5 years 4 months ago #178320
by marmo91
Include Yii::app in custom file was created by marmo91
Hi everyone,
Let's say I'm new in the Yii framework.
I'm trying to develop a custom plugin for a client.
I've already created a plugin that adds a menu item and points to a page containing an ajax form.
The form points to a custom file where I would like to include the core.
I tried to include the Yii class inlcuding the file /framework/yii.php, but if I try to access the properties of the class (example : Yii::app()->session) it returns me the following error:
"Notice: Trying to get property of non-object in C:\xampp\htdocs\limesurvey\plugins\multiGroupSurvey\ajax.php on line 19"
how can I initialize the class correctly inside my custom file?
Thank you all
Let's say I'm new in the Yii framework.
I'm trying to develop a custom plugin for a client.
I've already created a plugin that adds a menu item and points to a page containing an ajax form.
The form points to a custom file where I would like to include the core.
I tried to include the Yii class inlcuding the file /framework/yii.php, but if I try to access the properties of the class (example : Yii::app()->session) it returns me the following error:
"Notice: Trying to get property of non-object in C:\xampp\htdocs\limesurvey\plugins\multiGroupSurvey\ajax.php on line 19"
how can I initialize the class correctly inside my custom file?
Thank you all
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
5 years 4 months ago #178326
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Include Yii::app in custom file
You can include all limesurvey using
manual.limesurvey.org/NewDirectRequest
But for a admin form : just use
You just ahev to create yourMethod method and construct your form inside.
Sample code : gitlab.com/SondagesPro/managament/respon...stAndManage.php#L225
But for a admin form : just use
Code:
Yii::app()->createUrl('admin/pluginhelper',sa' =>'sidebody','plugin' =>get_class($this),'method' => 'yourMethod');
Sample code : gitlab.com/SondagesPro/managament/respon...stAndManage.php#L225
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
- marmo91
- Topic Author
- Offline
- New Member
Less
More
- Posts: 4
- Thank you received: 0
5 years 4 months ago - 5 years 4 months ago #178341
by marmo91
Replied by marmo91 on topic Include Yii::app in custom file
Thanks for the reply,
I had already tried this way with poor results, I got the following error:
<h1>PHP Error [400]</h1>
<p>The CSRF token could not be verified. (C:\xampp\htdocs\limesurvey\framework\web\CHttpRequest.php:1362)</p>
<pre>#0 C:\xampp\htdocs\limesurvey\framework\base\CErrorHandler.php(131): CErrorHandler->handleException()
#1 C:\xampp\htdocs\limesurvey\framework\base\CApplication.php(750): CErrorHandler->handle()
#2 unknown(0): LSYii_Application->handleException()
</pre>
Now I've set the "enableCsrfValidation" setting to false inside internal.php file and it works, but I don't know if it's the correct way.
I had already tried this way with poor results, I got the following error:
<h1>PHP Error [400]</h1>
<p>The CSRF token could not be verified. (C:\xampp\htdocs\limesurvey\framework\web\CHttpRequest.php:1362)</p>
<pre>#0 C:\xampp\htdocs\limesurvey\framework\base\CErrorHandler.php(131): CErrorHandler->handleException()
#1 C:\xampp\htdocs\limesurvey\framework\base\CApplication.php(750): CErrorHandler->handle()
#2 unknown(0): LSYii_Application->handleException()
</pre>
Now I've set the "enableCsrfValidation" setting to false inside internal.php file and it works, but I don't know if it's the correct way.
Last edit: 5 years 4 months ago by marmo91.
The topic has been locked.
- DenisChenu
- Offline
- LimeSurvey Community Team
Less
More
- Posts: 13637
- Thank you received: 2491
5 years 4 months ago #178360
by DenisChenu
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
Replied by DenisChenu on topic Include Yii::app in custom file
You have to use CHTML::beginForm :
www.yiiframework.com/doc/api/1.1/CHtml#beginForm-detail
in place of <form>
It's done for this
See gitlab.com/SondagesPro/managament/respon...iews/settings.php#L9 sample
in place of <form>
It's done for this
See gitlab.com/SondagesPro/managament/respon...iews/settings.php#L9 sample
Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The following user(s) said Thank You: marmo91
The topic has been locked.