Giter Club home page Giter Club logo

yii2-chosen's People

Contributors

beowulfenator avatar ezoterik avatar romeromsk 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

Watchers

 avatar  avatar  avatar  avatar

yii2-chosen's Issues

Newbie Question, Database Exception – yii\db\Exception

Good Day,

greetins Romero, i use your chosen extension and it´s amazing because works with BootStrap 3, but i have a newbie question, how to store array into database and get back on the view render for chosen?

what i do:

  1. after install it with composer, just add class namespace and add widget
    image
  2. then add rule on model for the input on safe items.
  3. try to create new record and var dump options with the var
    image
  4. but when i try store all data, give me errors
Database Exception – yii\db\Exception

PDOStatement::bindValue() expects parameter 2 to be long, string given
Failed to prepare SQL: INSERT INTO

Caused by: yii\base\ErrorException

PDOStatement::bindValue() expects parameter 3 to be long, string given

in C:\websites\reportes2\vendor\yiisoft\yii2\db\Command.php at line 271

5 so i try to convert it into string using implode(",", $model->miembros); but when got back to the form if are multiple items they not show on the input.

Few chosen on page

Hi. Please help me.
I'm trying to apply plugin to few form on one page, but chоsen applies to only for one select!
The forms on page is the same model.
This is my code:

<div class="form-group">
            <?php echo Html::activeLabel($model,'geo')?>
            <?= \nex\chosen\Chosen::widget([
                'model' => $model,
                'attribute' => 'geo',
                'items' => $arGeo,
                'multiple' => true,
            ]);?>
            <?php Html::error($model,'geo');?>
        </div>

1429096028458

How can i do it works?

Html tag "unselect" option

Why do you set $this->options['unselect'] = null inside init()? It is impossible to set unselect option then. For example, I currently faced a problem with editing many-to-many relations with chosen multiple. I need to set unselect option to send an empty value when no options are selected...

Some error in chosen.jquery.js

I've tried to use the example code

<?= $form->field($model, 'my_actual_attribute')->widget(
    Chosen::className(), [
        'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'],
        'disableSearch' => 5, // Search input will be disabled while there are fewer than 5 items
        'clientOptions' => [
            'search_contains' => true,
            'single_backstroke_delete' => false,
        ],
]);?>

And Google Chrome states that there is an error Uncaught TypeError: Cannot read property '0' of undefined in chosen.jquery.js on line #143

'chosen:ready' event not trigger

I suggest to use this code to register plugin events:

public function registerScript()
{
 ChosenBootstrapAsset::register($this->getView());
 $clientOptions = Json::encode($this->clientOptions);
 $id = $this->options['id'];
 $this->getView()->registerJs("jQuery('#$id'){$this->buildEvents()}
         .chosen({$clientOptions});");
}
protected function buildEvents() 
{
    if (!empty($this->clientEvents)) {
        $events = [];
        foreach ($this->clientEvents as $event => $handle) {
            $handle = new JsExpression($handle);
            $events[] = "on('{$event}', {$handle})";
        }
        return '.' . implode('.', $events);
    }
    return '';
}

And stub (or remove) registerEvents()

Other possible decision is use code above to register only "chosen:ready"

Version

Hi! Can you create at least one version? Its bad to use dev-master in composer.json.

Asset sourcepath issue

IMHO you shouldn't use '@vendor/nex/yii2-chosen/assets' value for asset source path, especially when you haven't composer package (users (like me) can put your extension in some other directory).

You can override init method and use "$this->sourcepath = dirname(FILE) . DIRECTORY_SEPARATOR . 'assets';" code to fix it. Or just register your extension as a composer package.

Bad $sourcePath for bower folder

ChosenAsset.php
public $sourcePath = '@vendor/bower/chosen';

ChosenBootstrapAsset.php
public $sourcePath = '@vendor/bower/chosen-bootstrap';

You should use alias '@bower' not '@vendor/bower' because at least my composer installed all bower assets under 'vendor/bower/bower-assets'. And this was the problem because your extension was looking into wrong path (vendor/bower/chosen but actual path is vendor/bower/bower-assets/chosen).

Yii2 creates @bower alias automatically when bootstrapping that corresponds to current application.

All my other third-party extensions are also using '@bower' instead of '@vendor/bower'.

UNABLE TO INSTALL THIS EXTENSION IN YII2

I ma unable to install this extension in yii2. composer shows error when i run this command

composer require "nex/yii2-chosen" "*"
Deprecation Notice: The Composer\Package\LinkConstraint\MultiConstraint class is
deprecated, use Composer\Semver\Constraint\MultiConstraint instead. in phar://C
:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Package/LinkConstrain
t/MultiConstraint.php:17
Deprecation Notice: The Composer\Package\LinkConstraint\LinkConstraintInterface
interface is deprecated, use Composer\Semver\Constraint\ConstraintInterface inst
ead. in phar://C:/ProgramData/ComposerSetup/bin/composer.phar/src/Composer/Packa
ge/LinkConstraint/LinkConstraintInterface.php:17
./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
- The requested package dbtek/chosen-bootstrap could not be found in any version, there may be a typo in the package name.
Problem 2
- The requested package nex/yii2-chosen could not be found in any version, there may be a typo in the package name.

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

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

please help ASAP
i need it in yii2 else show me the process for manual installation of this great extension.

Hardcoded 'app' message source in init()

If one has other category name for translations - errors in log

[yii\i18n\PhpMessageSource::loadMessages] The message file for category 'app' does not exist...

because of

$this->clientOptions['placeholder_text_single'] = \Yii::t('app', $this->placeholder ? $this->placeholder : 'Select an option');
$this->clientOptions['placeholder_text_multiple'] = \Yii::t('app', $this->placeholder ? $this->placeholder : 'Select some options');
$this->clientOptions['no_results_text'] = \Yii::t('app', 'No results match');

At least add tip to README that app message source should be configured to avoid hacking widget code.

Another way - add message source to widget options so one could pass custom message source and add this 3 lines to his translations file.

How to set selected options?

I have a activeform for update a Video information and it has a category field . I use yii2-chosen for show category. but this video has some default category how can i show them in the other words how can I show selected options in select tag?
<?= $form->field($model, 'tag')->widget( Chosen::className(), [ 'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'], 'multiple' => true, 'clientOptions' => [ 'search_contains' => true, 'single_backstroke_delete' => false, ], ]);?>

for example in this part of code I want to first item be selected

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.