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

Space character is not valid for ID attribute #568

Closed
Yasen opened this issue Mar 31, 2012 · 6 comments
Closed

Space character is not valid for ID attribute #568

Yasen opened this issue Mar 31, 2012 · 6 comments

Comments

@Yasen
Copy link
Contributor

Yasen commented Mar 31, 2012

Hello,

I'm using CHtml::getIdByName($name). However it does not replace spaces which are not valid for ID attributes. If ID contains spaces, the element cannot be selected by jQuery also. Thank you.

Yasen

@samdark
Copy link
Member

samdark commented Mar 31, 2012

Spaces in IDs aren't valid. That's true. Still you can select ids with spaces using jQuery:

$("[id='id with spaces']").show();

@suralc
Copy link
Contributor

suralc commented Mar 31, 2012

Yeah, but I think atleast the core classes should generate valid html.

@Yasen
Copy link
Contributor Author

Yasen commented Apr 1, 2012

Thanks for the hint samdark :)

@mdomba
Copy link
Member

mdomba commented Apr 2, 2012

@samdark, @qiangxue should we close this ticket (leave as it is) or add the check for spaces too (convert spaces to _ or even empty)

@qiangxue
Copy link
Member

qiangxue commented Apr 2, 2012

I don't know under which situation we will see names containing spaces. But
since the fix is trivial, I think we can convert spaces into _.

On Mon, Apr 2, 2012 at 7:12 AM, Maurizio Domba <
reply@reply.github.com

wrote:

@samdark, @qiangxue should we close this ticket (leave as it is) or add
the check for spaces too (convert spaces to _ or even empty)


Reply to this email directly or view it on GitHub:
#568 (comment)

@mdomba
Copy link
Member

mdomba commented Apr 2, 2012

I guess this can happen if the developer calls this method with some custom values... agree with you to fix this as I don't see why would anybody insist in having spaces in the name.

Will fix this asap.

mdomba pushed a commit that referenced this issue Apr 2, 2012
Fixes issue #568 - added check for space in CHtml::getIdByName()
@mdomba mdomba closed this as completed Apr 2, 2012
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

5 participants