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

Inline display does not allow using altField option #87

Open
buttflattery opened this issue Jul 7, 2019 · 10 comments
Open

Inline display does not allow using altField option #87

buttflattery opened this issue Jul 7, 2019 · 10 comments
Assignees
Labels
Milestone

Comments

@buttflattery
Copy link

buttflattery commented Jul 7, 2019

What steps will reproduce the problem?

Create a datepicker with the following options where you use inline option along with the altField option

echo DatePicker::widget([
    'name' => 'date_range',
    'inline' => true,
    'clientOptions' => [
        'selectOtherMonths' => true,
        'altField' => '#shootssearch-created_at',
    ]
]);

and create an active field using yii\helpers\Html or ActiveForm to be used as an actual form field to be submitted along with the datepicker value when form is submitted.

echo Html::activeTextInput($model, 'created_at');

What's expected?

i expect the field to be populated with the date value selected from the datepicker

What do you get instead?

nothing happens and the field stays blank

The reason behind is that for inline display you have the following code on line 201 in renderWidget() function

$this->clientOptions['altField'] = '#' . $this->options['id'];

which overrides the custom defined altField .

you can change that line to something like below which will work for both cases

  • default hidden field created by the widget.
  • the custom field if the user defines one using the altField .
$customAltField = yii\helprs\ArrayHelper::getValue($this->clientOptions, 'altField', false);
$this->clientOptions['altField'] = '#' . $this->options['id'];
if ($customAltField) {
    $this->clientOptions['altField'] .=  ', ' . $customAltField;
}

Additional info

Q A
Yii vesion 2.0.20
PHP version 5.6
Operating system Windows 10
@samdark samdark added status:ready for adoption Feel free to implement this issue. type:bug Bug labels Jul 7, 2019
@samdark
Copy link
Member

samdark commented Jul 7, 2019

Thanks for reporting. Feel free to do a pull request.

@buttflattery
Copy link
Author

@samdark sure, but i havent contributed before in any of Yii's repo, are there any guidelines to follow ?

@samdark
Copy link
Member

samdark commented Jul 7, 2019

@samdark samdark removed the status:ready for adoption Feel free to implement this issue. label Jul 7, 2019
@samdark samdark added the status:under development Someone is working on a pull request. label Jul 7, 2019
@buttflattery
Copy link
Author

@samdark what i understand is that i have to fork and clone the main Yii2 repo first to contribute the fix to this extension. am i right ? or should i do those 3 steps for the extensions repo directly rather than the Main Yii2 repo first? which i dont think so is the right way.

Sorry to bug you about this.

@samdark
Copy link
Member

samdark commented Jul 7, 2019

Yes, you are right. Yii2 repo first.

@samdark
Copy link
Member

samdark commented Jul 23, 2019

Any luck with the pull request?

@buttflattery
Copy link
Author

buttflattery commented Jul 24, 2019

@samdark forgot totally as i was busy lately, just going to push the code can you tell if the CHANGELOG entry will go under 2.0.8 under development section ? i am sure it goes under that.

@samdark
Copy link
Member

samdark commented Jul 25, 2019

Merging is blocked as expected since we need to check the pull request first.

@samdark samdark removed the status:under development Someone is working on a pull request. label Jul 25, 2019
@samdark samdark added this to the 2.0.8 milestone Jul 25, 2019
@buttflattery
Copy link
Author

@samdark alright, and dont you think a test for the altField with inline display mode should be added too.

@samdark
Copy link
Member

samdark commented Jul 28, 2019

Yes, sure it should.

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

No branches or pull requests

2 participants