Giter VIP home page Giter VIP logo

yii2-settings's People

Contributors

antongorodezkiy avatar arisk avatar cinghie avatar demroos avatar dinhtrung avatar grzegorzkurtyka avatar gugoan avatar jafaripur avatar ksideks avatar monster-hunter avatar pakey avatar pawelkania avatar prawee avatar requilence avatar rsol avatar schmunk42 avatar sensetivity avatar uldisn avatar zacksleo avatar zayec77 avatar zorobabel avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-settings's Issues

Empty settings input fields saved as object

I'm having a problem when save a settings form with empty fields. Empty field saved as object and get an error because the field is an object instead a string.

PHP Recoverable Error – yii\base\ErrorException
Object of class stdClass could not be converted to string

The problem is in setSetting method of BaseSetting class, the method do not consider empty string case and set it as object:

if ($type !== null) {
$model->type = $type;
} else {
$t = gettype($value);
if ($t == 'string') {
$error = false;
try {
Json::decode($value);
} catch (InvalidParamException $e) {
$error = true;
}
if (!$error) {
$t = 'object';
}
}
$model->type = $t;
}

Update this extension for new version of Yii framework(2.0.14)

C:\xampp\htdocs\sites\yii2-shop>composer require --prefer-dist pheme/yii2-settin
gs "*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- Installation request for sebastian/resource-operations (locked at 2.0.x-de
v) -> satisfiable by sebastian/resource-operations[2.0.x-dev].
- phpunit/phpunit 6.5.x-dev requires sebastian/resource-operations ^1.0 -> s
atisfiable by sebastian/resource-operations[1.0.0].
- phpunit/phpunit 6.5.x-dev requires sebastian/resource-operations ^1.0 -> s
atisfiable by sebastian/resource-operations[1.0.0].
- phpunit/phpunit 6.5.x-dev requires sebastian/resource-operations ^1.0 -> s
atisfiable by sebastian/resource-operations[1.0.0].
- Conclusion: don't install sebastian/resource-operations 1.0.0
- Installation request for phpunit/phpunit (locked at 6.5.x-dev, required as
~6.5.5) -> satisfiable by phpunit/phpunit[6.5.x-dev].

Installation failed, reverting ./composer.json to its original content.

Update your extension, please

Using with sqlite

When I try to create new settings or edit I get error

SQLSTATE[HY000]: General error: 1 no such function: NOW
Failed to prepare SQL: INSERT INTO `settings` (`active`, `section`, `key`, `value`, `type`, `created`) VALUES (:qp0, :qp1, :qp2, :qp3, :qp4, NOW())

I am using sqlite database, seems like there is no function NOW there. How do I fix the problem?

add option to create entry on get()

How about adding a forth parameter to get() which would create a deactivated entry, if there is no setting in the database yet?

Static helper as an example:

class Settings
{
    static function get($key, $section, $default = null, $create = true)
    {
        $value = \Yii::$app->settings->get($key, $section, $default);
        if ($value === $default && $create !== false) {
            \Yii::$app->settings->set($key, $default, $section);
            \Yii::$app->settings->deactivate($key, $section);
        }
        return $value;
    }
}

Any thoughts?

PS: I think the check should be improved a bit...

Dynamic Form Rendered out of Section

I would like to suggesting automatically created forms. like a form is created by a category. All of the keys concerning that category are inputs. Of course, which should be updated. This would be a great enhancement

Default value on get setting

Thank you for this extension. It`s very usefull.
But it will be better to add default value in get, when the setting is not set.
f.e.
$value = $settings->get('section.key',10); If not "section.key" set, we get $value=10;

Exception on getting empty value which was saved as an object in db

Hello! I'm getting an exception while trying to get an empty value which was saved as an object in db (field "type")

web.php:

'modules' => [
        'settings' => [
          'class' => 'pheme\settings\Module',
          'sourceLanguage' => 'ru'
        ],
    ],
'settings' => [
      'class' => 'pheme\settings\components\Settings'
],

controller:

          'social-service' => [
                'class' => 'pheme\settings\SettingsAction',
                'modelClass' => 'app\models\SocialService',
                'viewName' => 'social-service'   // The form we need to render
            ],

view:

<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\Url;

/* @var $this yii\web\View */
/* @var $model app\models\Page */
/* @var $form yii\widgets\ActiveForm */


?>

<?php $form = ActiveForm::begin(['id' => 'social-service-form']); ?>
<?= $form->field($model, 'twitter')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'google')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'facebook')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'youtube')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'linkedin')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'pinterest')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'vimeo')->textInput()  ?>
<?= $form->field($model, 'instagram')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'vk')->textInput([
                                 'type' => 'text'
                            ])  ?>
<?= $form->field($model, 'ok')->textInput([
                                 'type' => 'text'
                            ])  ?>

<div class="form-group">
        <?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
    </div>

    <?php ActiveForm::end(); ?>

model:

class SocialService extends Model 
{

    public $twitter;
    public $google;
    public $facebook;
    public $youtube;
    public $linkedin;
    public $pinterest;
    public $vimeo;
    public $instagram;
    public $vk;
    public $ok;

    public function rules()
    {
        return [
            [['twitter','google','facebook','youtube','linkedin','pinterest','vimeo','instagram','vk','ok'], 'string'],
        ];
    }

    public function fields()
    {
            return ['twitter','google','facebook','youtube','linkedin','pinterest','vimeo','instagram','vk','ok'];
    }

    public function attributes()
    {
            return ['twitter','google','facebook','youtube','linkedin','pinterest','vimeo','instagram','vk','ok'];
    }
}

When I'm trying to save empty fields (e.g. user don't want to fill some of them), I'm getting following error:

 PHP Recoverable Error – yii\base\ErrorException
Object of class stdClass could not be converted to string

in D:\OpenServer\domains\localhost\vendor\yiisoft\yii2\helpers\BaseHtml.php

     * See [[renderTagAttributes()]] for details on how attributes are being rendered.
     * @return string the generated input tag
     */
    public static function input($type, $name = null, $value = null, $options = [])
    {
        if (!isset($options['type'])) {
            $options['type'] = $type;
        }
        $options['name'] = $name;
                                                               $options['value'] = $value === null ? null : (string) $value;
        return static::tag('input', '', $options);

as I've noticed it's all because of:

BaseSetting.php

 public function setSetting($section, $key, $value, $type = null)
    {
        $model = static::findOne(['section' => $section, 'key' => $key]);

        if ($model === null) {
            $model = new static();
            $model->active = 1;
        }
        $model->section = $section;
        $model->key = $key;
        $model->value = strval($value);

        if ($type !== null) {
            $model->type = $type;
        } else {
            $t = gettype($value);
            if ($t == 'string') {
                $error = false;
                try {
                    Json::decode($value);
                } catch (InvalidParamException $e) {
                    $error = true;
                }
                /*if (!$error) {
                    $t = 'object';
                }*/
            }
            $model->type = $t;
        }

        return $model->save();
    }

So, the question is how to save this form correctly?

Unknown property exception upon executing migration script

I installed the settings plugin via composer, but when I'm trying to create tables using migration script, I encountered the following issue. Any idea?

C:\projects\proj>yii migrate/up --migrationPath=@vendor/pheme/yii2-settings/migrations
←[0m←[31;1mException←[0m←[0m←[1;34m 'yii\base\UnknownPropertyException'←[0m with message ←[0m←[1m'Setting unknown property: yii\console\Request::enableCsrfValidation'←[0m

in C:\projects\proj\vendor\yiisoft\yii2\base\←[0m←[1mComponent.php←[0m:←[0m←[1;33m197←[0m

←[0m←[1mStack trace:
←[0m#0 C:\projects\med-appt\vendor\yiisoft\yii2\BaseYii.php(518): yii\base\Component->__set('enableCsrfValid...', false)
#1 C:\projects\med-appt\vendor\yiisoft\yii2\base\Object.php(105): yii\BaseYii::configure(Object(yii\console\Request), Array)

C:\projects\med-appt\vendor\yiisoft\yii2\di\Container.php(372): ReflectionClass->newInstanceArgs(Array)
C:\projects\med-appt\vendor\yiisoft\yii2\di\Container.php(151): yii\di\Container->build('yii\console\Req...', Array, Array)
C:\projects\med-appt\vendor\yiisoft\yii2\BaseYii.php(344): yii\di\Container->get('yii\console\Req...', Array, Array)
C:\projects\med-appt\vendor\yiisoft\yii2\di\ServiceLocator.php(133): yii\BaseYii::createObject(Array)
C:\projects\med-appt\vendor\yiisoft\yii2\base\Application.php(536): yii\di\ServiceLocator->get('request')
C:\projects\med-appt\vendor\yiisoft\yii2\base\Application.php(375): yii\base\Application->getRequest()
C:\projects\med-appt\yii(31): yii\base\Application->run()
{main}

Cannot use SettingAction form a custom form

Hi,
I tried to use SettingAction to make a custom form to handle a setting category. There are several things I did not understand, so it doesn't work. Could you please provide an fully working example?
thanks Roberto

How to disable cache?

I Have a problem:
I setting up parameters via Backend application and using the same parameters in Frontend side but caching saving old values

Broken backwards-compability since 0.3

I don't use module, just component
Since you've added translations in 0.3, I get an error "Unable to locate message source for category 'extensions/yii2-settings/settings" while validating Setting model
It happens because module is never initialized, but Module::t is called

Custom form and upload image

I'll try to explain.
I'd like to have a setting item in my custom form like farm.logo that uploads an image and save the path.
It's too much :-)
Thanks Roberto

GUI insert/update: does not clear cache

Whenever I insert or update the values, it returns null or the previous value. I need to clear the cache explicityly. I wuold suggest to automatically update the module's cache

Table prefix

Hi!
When i run migrations, at DB i got the table "settings" with my prefix "cs_settings".
But in model(Settings) method "public static function tableName()" return table name without prefix, and I got error "table not found".
I think need add return '{{%settings}}' to method "public static function tableName()"

Sort list alphabetically

Could we sort the settings list by default section ASC, key ASC?

It's easier to find a setting, IMHO.

[addon]
A 0.4.1 or 0.5.0 release would also be nice 👍

Cache not cleared on save in module

It seems that when a setting is saved in the module, the cache is not cleared. The app still sees the old setting value. Calling $settings->clearCache() flushes the cache and then the value is correct.

Is this expected behavior, or should the module flush the cache on setting save?

Object of class stdClass could not be converted to string

I have a custom form to save settings, always works fine until after last update.
Now i get th error
Object of class stdClass could not be converted to string
in my form there is a checkbox

field($model, 'accettazione_condizioni')->checkbox() ?>

To riproduce the error put a checkbox in any cuostom form.
Could you help me?
Roberto

GUI insert/update: does not clear cache

Whenever I insert or update the values, it returns null or the previous value. I need to clear the cache explicityly. I wuold suggest to automatically update the module's cache

Settings cache problem

Hi. I install your module. Add action to my settings controller. Create model and view for settings interface. If i submit form, all settings save to DB and all work fine, but if i clear cache, all fileds in view are empty. But in DB it`s already exist. Can you help to fix it?
Thank you for your work. Module is great.

Invalid type when set type is "email"

I got error when set a setting's type is "email".

It seems PHP [settype](http://php.net/manual/en/function.settype.php) function doesn't support email type.

Possibles values of type are:

"boolean" (or, since PHP 4.2.0, "bool")
"integer" (or, since PHP 4.2.0, "int")
"float" (only possible since PHP 4.2.0, for older versions use the deprecated variant "double")
"string"
"array"
"object"
"null" (since PHP 4.2.0)

yii2-toggle-column require problem

Hi. Try to install your module on other project, but composer say
Problem 1
- The requested package pheme/yii2-toggle-column could not be found in any version, there may be a typo in the package name.
Problem 2
- Installation request for pheme/yii2-settings dev-master -> satisfiable by pheme/yii2-settings[dev-master].
- pheme/yii2-settings dev-master requires pheme/yii2-toggle-column * -> no matching package found

How can i install it?

add 0.3 release

Would be nice if you could release a 0.3 version, we're working on 8c81f47 without problems.
I think the access control is a crucial new feature.

Thanks in advance.

Tabbed interface

Change the view interface to use a tabbed format. Each tab should represent a section in the DB.

Database Exception after installating

Hi,

I installed version 0.3 via composer and ran the migration scripts. Further, I added the relevant sections to the configuration. However I get the following error when accessing the "/settings" module:

Database Exception – yii\db\Exception
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'judotm.Setting' doesn't exist
The SQL being executed was: SELECT DISTINCT `section` FROM `Setting`

Error Info: Array
(
    [0] => 42S02
    [1] => 1146
    [2] => Table 'judotm.Setting' doesn't exist
)

↵
Caused by: PDOException
SQLSTATE[42S02]: Base table or view not found: 1146 Table 'judotm.Setting' doesn't exist

in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 837

Seems like the module tries to access the Settings-table with capital S. I verified that the table exists, however with a small s.

mysql> use judotm

Database changed
mysql> show tables;
+------------------+
| Tables_in_judotm |
+------------------+
| ...              |
| settings         |
| ...              |
+------------------+
11 rows in set (0,00 sec)

mysql> describe settings;
+----------+--------------+------+-----+---------+----------------+
| Field    | Type         | Null | Key | Default | Extra          |
+----------+--------------+------+-----+---------+----------------+
| id       | int(11)      | NO   | PRI | NULL    | auto_increment |
| type     | varchar(255) | NO   |     | NULL    |                |
| section  | varchar(255) | NO   | MUL | NULL    |                |
| key      | varchar(255) | NO   |     | NULL    |                |
| value    | text         | YES  |     | NULL    |                |
| active   | tinyint(1)   | YES  |     | NULL    |                |
| created  | datetime     | YES  |     | NULL    |                |
| modified | datetime     | YES  |     | NULL    |                |
+----------+--------------+------+-----+---------+----------------+
8 rows in set (0,00 sec)

Stack Trace:

1. in /var/www/html/hc/vendor/yiisoft/yii2/db/Schema.php at line 628
2. in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 852 – yii\db\Schema::convertException(PDOException, 'SELECT DISTINCT `section` FROM `...')
3. in /var/www/html/hc/vendor/yiisoft/yii2/db/Command.php at line 359 – yii\db\Command::queryInternal('fetchAll', null)
4. in /var/www/html/hc/vendor/yiisoft/yii2/db/Query.php at line 206 – yii\db\Command::queryAll()
5. in /var/www/html/hc/vendor/yiisoft/yii2/db/ActiveQuery.php at line 132 – yii\db\Query::all(null)
6. in /var/www/html/hc/vendor/yii2mod/yii2-settings/views/default/index.php at line 38 – yii\db\ActiveQuery::all()
7. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 325 – require('/var/www/html/hc/vendor/yii2mod/...')
8. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 247 – yii\base\View::renderPhpFile('/var/www/html/hc/vendor/yii2mod/...', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider])
9. in /var/www/html/hc/vendor/yiisoft/yii2/base/View.php at line 149 – yii\base\View::renderFile('/var/www/html/hc/vendor/yii2mod/...', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider], yii2mod\settings\controllers\DefaultController)
10. in /var/www/html/hc/vendor/yiisoft/yii2/base/Controller.php at line 371 – yii\base\View::render('index', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider], yii2mod\settings\controllers\DefaultController)
11. in /var/www/html/hc/vendor/yii2mod/yii2-settings/controllers/DefaultController.php at line 61 – yii\base\Controller::render('index', ['searchModel' => yii2mod\settings\models\search\SettingModelSearch, 'dataProvider' => yii\data\ActiveDataProvider])
12. yii2mod\settings\controllers\DefaultController::actionIndex()
13. in /var/www/html/hc/vendor/yiisoft/yii2/base/InlineAction.php at line 55 – call_user_func_array([yii2mod\settings\controllers\DefaultController, 'actionIndex'], [])
14. in /var/www/html/hc/vendor/yiisoft/yii2/base/Controller.php at line 151 – yii\base\InlineAction::runWithParams([])
15. in /var/www/html/hc/vendor/yiisoft/yii2/base/Module.php at line 455 – yii\base\Controller::runAction('', [])
16. in /var/www/html/hc/vendor/yiisoft/yii2/web/Application.php at line 84 – yii\base\Module::runAction('settings', [])
17. in /var/www/html/hc/vendor/yiisoft/yii2/base/Application.php at line 375 – yii\web\Application::handleRequest(yii\web\Request)
18. in /var/www/html/hc/web/index.php at line 12 – yii\base\Application::run()

Any idea what the problem could be? Thanks in advance

How to use type array?

I couldn't figure it out, how can I write and read array via PHP code and WebUI?
Could you add an example to the docs?

Migration Fails with Exception: SQLSTATE[42000]: Syntax error or access violation: 1071

Hello, and thanks for such a great Yii2 extension!

Running the settings migration on my local machine worked perfectly. However, when I go to run the migration on my testing server, I am receiving the following error:
create unique index settings_unique_key_section on {{%settings}} (section,key) ...Exception: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 1000 bytes

I've briefly researched this SQL error, and it seems to be related to the database encoding and field lengths, but I can't say that I understand it completely. The following posts seem to address this issue:
http://stackoverflow.com/questions/10642429/error-1071-specified-key-was-too-long-max-key-length-is-1000-bytes-mysql
http://stackoverflow.com/questions/1814532/1071-specified-key-was-too-long-max-key-length-is-767-bytes/1814594#1814594

I ended up creating a custom migration file that I can run during deployment. You'll note in the migration file below that I had to explicitly set the encoding to be utf8 via the tableOptions. By explicitly setting the utf8 encoding, the error went away and my testing server was happy again :)

Just thought I'd share this info in case anyone else runs into a similar challenge.

class m160521_165503_pheme_settings_tables extends \yii\db\Migration
{
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }

        $this->createTable(
            '{{%settings}}',
            [
                'id' => $this->primaryKey(),
                'type' => $this->string(255)->notNull(),
                'section' => $this->string(255)->notNull(),
                'key' => $this->string(255)->notNull(),
                'value' => $this->text(),
                'active' => $this->boolean(),
                'created' => $this->dateTime(),
                'modified' => $this->dateTime(),
            ],
            $tableOptions
        );
        $this->createIndex('settings_unique_key_section', '{{%settings}}', ['section', 'key'], true);
    }

    public function down()
    {
        $this->dropIndex('settings_unique_key_section', '{{%settings}}');
        $this->dropTable('{{%settings}}');
    }
}

remove frontCache

Maybe I am overlooking something, but is frontCache in use at all?
I looked through the code and found only cache to hold values.

Findings for frontCache:
bildschirmfoto 2016-04-14 um 22 06 35

Class pheme\settings\components\Settings does not exist

Include in component section config.
All files located in vendro folder (install via via composer)
Run \Yii::$app->settings
Got:
ReflectionException
Class pheme\settings\components\Settings does not exist
Whats problem? ;[

if i'll do: var_dump(\Yii::$app);
it loaded:
["settings"]=>
array(1) {
["class"]=>
string(34) "pheme\settings\components\Settings"
}

Problem in editable save state

I get this error message.
When I change the configuration state via the editable interface

exception 'yii\base\UnknownPropertyException' with message 'Getting unknown property: yii\web\Application::settings' in C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\base\Component.php:154
Stack trace:
#0 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\di\ServiceLocator.php(77): yii\base\Component->__get('settings')
#1 C:\OSPanel\domains\splitstore.open\vendor\yii2mod\yii2-settings\models\SettingModel.php(107): yii\di\ServiceLocator->__get('settings')
#2 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\db\BaseActiveRecord.php(825): yii2mod\settings\models\SettingModel->afterSave(false, Array)
#3 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\db\ActiveRecord.php(676): yii\db\BaseActiveRecord->updateInternal(NULL)
#4 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\db\BaseActiveRecord.php(681): yii\db\ActiveRecord->update(false, NULL)
#5 C:\OSPanel\domains\splitstore.open\vendor\yii2mod\yii2-editable\EditableAction.php(74): yii\db\BaseActiveRecord->save(false)
#6 [internal function]: yii2mod\editable\EditableAction->run()
#7 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\base\Action.php(94): call_user_func_array(Array, Array)
#8 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\base\Controller.php(157): yii\base\Action->runWithParams(Array)
#9 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\base\Module.php(528): yii\base\Controller->runAction('edit-setting', Array)
#10 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\web\Application.php(103): yii\base\Module->runAction('settings/defaul...', Array)
#11 C:\OSPanel\domains\splitstore.open\vendor\yiisoft\yii2\base\Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#12 C:\OSPanel\domains\splitstore.open\backend\web\index.php(17): yii\base\Application->run()
#13 {main}
    "require": {
        "php": ">=5.6.0",
        "yiisoft/yii2": "~2.0.14",
        "yiisoft/yii2-bootstrap": "~2.0.0",
        "yiisoft/yii2-swiftmailer": "~2.0.0 || ~2.1.0",
        "yiisoft/yii2-imagine": "*",
        "dmstr/yii2-adminlte-asset": "*",
        "kartik-v/yii2-widget-datepicker": "@dev",
        "mihaildev/yii2-ckeditor": "@dev",
        "guzzlehttp/guzzle": "*",
        "electrolinux/phpquery": "^0.9.6",
        "codemix/yii2-excelexport": "*",
        "cebe/yii2-gravatar": "*",
        "yii2mod/yii2-settings": "*"
    },
    "require-dev": {
        "yiisoft/yii2-debug": "~2.1.0",
        "yiisoft/yii2-gii": "~2.1.0",
        "yiisoft/yii2-faker": "~2.0.0",
        "codeception/codeception": "^4.0",
        "codeception/module-asserts": "^1.0",
        "codeception/module-yii2": "^1.0",
        "codeception/module-filesystem": "^1.0",
        "codeception/verify": "~0.5.0 || ~1.1.0",
        "symfony/browser-kit": ">=2.7 <=4.2.4",
        "insolita/yii2-migration-generator": "*"
    },

problem save

error display: strcmp() expects parameter 2 to be string, object given
file in /app/vendor/yiisoft/yii2/helpers/BaseHtml.php line 1913
POST value = "1"

//vendor/pheme/yii2-settings/models/BaseSetting.php

        if ($type !== null) {
            $model->type = $type;
        } else {
            $t = gettype($value);
            if ($t == 'string') {//t = "string" - this is correct
                $error = false;
                try {
                    Json::decode($value);//value "1" decode in 1
                } catch (InvalidParamException $e) {
                    $error = true;
                }
                if (!$error) {//if success decode and $t = "object" - wtf!!!???
                    $t = 'object';
                }
            }
            $model->type = $t;
        }

Custom form, numeric input problem

Hi,
in my custom form I added a normal string field.
When I save the data if I insert a string everything is ok but if I enter a number an error occurs.
PHP Recoverable Error – yii\base\ErrorException
Object of class stdClass could not be converted to string
I noticed that it does not store the data as string type but as object type?
Could you help me, please?
Roberto

Table Prefix

Hello, method tableName() in Setting model not return table name with prefix. I think this right version:
public static function tableName()
{
return '{{%settings}}';
}

Thank you.

Wrong Code

models/Settings.php

in setSetting function:

if ($type === null) {
$model->type = $type;
} else {
$model->type = gettype($value);
}

This's correct;

if ($type !== null) {
$model->type = $type;
} else {
$model->type = gettype($value);
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.