Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editable InputType Widget Problem #10

Closed
tof06 opened this issue Sep 25, 2014 · 2 comments
Closed

Editable InputType Widget Problem #10

tof06 opened this issue Sep 25, 2014 · 2 comments
Labels

Comments

@tof06
Copy link
Contributor

tof06 commented Sep 25, 2014

Hi,

I'm trying to use Editable::INPUT_WIDGET input type (inside an EditableColumn but I think the problem exists also in Editable widget).

This line (https://github.com/kartik-v/yii2-editable/blob/master/editable/Editable.php#L394) is never reached because INPUT_WIDGET is in array $_inputList

/* ... *.
private static $_inputsList = [
        self::INPUT_HIDDEN => 'hiddenInput',
/*.....*/
        self::INPUT_WIDGET => 'widget',
    ];

/*.....*/
 if ($this->inputType === self::INPUT_HTML5_INPUT) {
            echo $this->renderHtml5Input();
        } elseif (in_array($this->inputType, static::$_inputsList)) {
            echo $this->renderInput();
        } elseif (in_array($this->inputType, static::$_inputWidgets)) {
            echo $this->renderWidget($this->inputType);
        } elseif ($this->inputType === self::INPUT_WIDGET) {
            $class = ArrayHelper::remove($this->_inputOptions, 'class', '');

So, I tried to remove it from the array, and now, I have another problem when the widget is created.
You are using class entry in the option array, but this entry is also used for Css.
I suggest to rename it to widgetClass

Here's a portion of my code:

[
                        'class' => EditableColumn::className(),
                        'attribute' => 'date',
                        'header' => 'Date',
                        'format' => ['date', 'php:d/m/Y'],
                        'hAlign' => GridView::ALIGN_CENTER,
                        'options' => [
                            'class' => 'col-md-1',
                        ],
                        'editableOptions' => function ($model, $key, $index) {
                            return [
                                'format' => Editable::FORMAT_LINK,
                                'header' => 'Date du créneau',
                                'preHeader' => Icon::show('pencil'),
                                'size' => 'sm',
                                'placement' => PopoverX::ALIGN_TOP,
                                'inputType' => Editable::INPUT_WIDGET,

                                'options' => [
                                    'class' => DateControl::className(),
                                    'pluginOptions' => [
                                        'language' => 'fr',
                                    ],
                                ],
                                'submitButton' => [
                                    'label' => Icon::show('check') . 'Appliquer',
                                    'class' => 'btn btn-primary'
                                ]
                            ];
                        }
                    ],

I'll send you a PR with my changes.

Thanks.

@kartik-v
Copy link
Owner

Thanks. There's probably a slightly better way fix to this. Will check and update.

@kartik-v
Copy link
Owner

You have a separate widgetClass property now - that will need to be read only when inputType is INPUT_WIDGET.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants