Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

3.0 - FormHelper add idPrefix option #2952

Closed
markstory opened this Issue · 3 comments

2 participants

@markstory
Owner

Currently in 3.0, FormHelper has the chance of generating invalid ID attributes when creating multi-record forms. It also has 0 protection against duplicated ID attributes. Instead of implementing a way to track and increment ID's a more simple solution would be to add an idPrefix option to create():

echo $this->Form->create($article, ['idPrefix' => 'article']);

Then when input() is called the id's would automatically be prefixed with article-. Some additional rules around id prefixing:

  • The prefix would not be applied when the id attribute is defined.
  • ID prefixing would occur in the various places ID's are generated by FormHelper, including radio/multi-checkbox.
@markstory markstory added this to the 3.0.0 milestone
@markstory markstory self-assigned this
@ADmad
Collaborator

Currently input() and label() use _domId() to generate the ids. Instead shouldn't the FormHelper also use the IdGeneratorTrait by either modifying it's _id() method as required or by simply moving FormHelper::_domId() to IdGeneratorTrait::_domId()?

@markstory
Owner

That sounds like a reasonable plan. We would also need to make each of the widgets aware of the idPrefix option and have them use it.

@ADmad ADmad referenced this issue
Merged

3.0 form idprefix #2980

@markstory
Owner

Closing, as #2980 has been opened.

@markstory markstory closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.