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

Incomplete label attributes for widgets due to hardcoded group types #11850

Closed
1 of 3 tasks
rchavik opened this issue Mar 20, 2018 · 0 comments
Closed
1 of 3 tasks

Incomplete label attributes for widgets due to hardcoded group types #11850

rchavik opened this issue Mar 20, 2018 · 0 comments

Comments

@rchavik
Copy link
Member

rchavik commented Mar 20, 2018

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.5.12

  • Platform and Target: N/A

What you did

Croogo has a DateTimeWidget that renders a text input for integration with datetimepicker.

What happened

The widget is rendered with its <label> element missing the for attribute. Eg:

<div class="form-group datetime">
  <label class="col-form-label">Start Date</label>
  <input name="start_date" value="2018-03-19 17:00:00" id="start-date" type="hidden">
  <div class="input-group datetime ">
    <!-- removed for clarity -->
  </div>
</div>

What you expected to happen

The <label> should contain the appropriate for attribute`, eg:

<div class="form-group datetime">
  <label class="col-form-label" for="start-date">Start Date</label>
  <input name="start_date" value="2018-03-19 17:00:00" id="start-date" type="hidden">
  <div class="input-group datetime ">
    <!-- removed for clarity -->
  </div>
</div>

The reason is https://github.com/cakephp/cakephp/blob/master/src/View/Helper/FormHelper.php#L1505 assumes that a datetime is in $groupTypes causing forceful set of for to false.

There's no way AFAIK to bypass this aside by overriding the whole _inputLabel() method. Ideally, this should be configurable or obtained from the widget.

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

No branches or pull requests

3 participants