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

3.8.* does not merge form control attributes #13427

Closed
1 of 3 tasks
bugezzy opened this issue Jul 18, 2019 · 3 comments
Closed
1 of 3 tasks

3.8.* does not merge form control attributes #13427

bugezzy opened this issue Jul 18, 2019 · 3 comments

Comments

@bugezzy
Copy link

bugezzy commented Jul 18, 2019

This is a (multiple allowed):

  • bug

  • enhancement

  • feature-discussion (RFC)

  • CakePHP Version: 3.8.1

  • Platform and Target: Ubuntu 18, Nginx 1.14, MariaDB 10.1

What you did

I have added custom form controls in src/Plugins/Name/config/form-controls.php
Which states:
'input' => '<input type="{{type}}" name="{{name}}" class="form-control" {{attrs}} />',

I have told cake to use this plugin by setting this in my AppView:
$this->loadHelper('Form', ['templates' => 'Name.form-controls']);

I have told the add.ctp to include a class attribute src/Template/Users/add.ctp
<?php echo $this->Form->text('first_name',['required', 'class' => 'large']); ?>

What happened

The resulting HTML is rendered as:
<input type="text" name="last_name" class="form-control" required="required">

What you expected to happen

The expected HTML should be:
<input type="text" name="last_name" class="form-control large" required="required">

Previous versions did merge the attributes. Since 3.8 it ignores and additional classes added in the template files.

@markstory
Copy link
Member

Your class attribute in your template has no placeholders for class name. The string templates are simple and don't parse the template string to manipulate classnames.

In which previous version did your template generate the html you are expecting?

@bugezzy
Copy link
Author

bugezzy commented Jul 18, 2019

You are correct. The previous versions handles this the same way. Please disregard, maybe change this to a feature request.

@ADmad
Copy link
Member

ADmad commented Jul 18, 2019

Closing as how string templates work is unlikely to change. We won't be resorting to string manipulations.

@ADmad ADmad closed this as completed Jul 18, 2019
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