Modyfing code completion in PhpStorm 5 - phpstorm

After entering first characters of <textarea> tag and using autocomplete ( e.g. <texta and hitting ENTER) editor generates following snippet: <textarea rows="" cols=""
It's extremely unhelpful since I don't use rows and cols attributes.
How can I modify those snippets ?
I tried "Live templates" section but it's not there.

In this case code completion is performed according to the DTD, which defines rows and cols attributes of the textarea tag as Required.
Most likely your file starts with:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
or the default HTML language level defines it.
To address this problem you can create HTML 5 files with <!DOCTYPE html> and PhpStorm will stop completing these attributes.
See also the related IDE setting:

Related

Textbox displayed instead of checkbox

I have very unusual problem. I've created an HTML form with all types of inputs.
Then I put it on a server and what happened took me to the ground literally. All my checkboxes turned into textboxes. The code I put on my website has checkboxes in it, but when I use firebug it says it has textboxes there.
-HTML code is valid:
<input name="ksh" type="checkbox" id="ksh" />
I tried on a different server, it works fine there, so I assume it's a server-based problem. But I have no idea what can cause that. Any ideas?
I'd be thankful for any tips.
Thanks in advance
EDIT
Because I forgot and this may be an important factor I also paste doctype declaration:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
EDIT 2
http://larte2002.vizz.pl/gosc/bl/cennik/ <- client's server, which shows textboxes
http://89.65.65.3/BL/cennik/ <- my server, checkboxes
Content on servers is exactly the same on both!
According to this, for checkboxes the format is input type="checkbox" name="boxname" value="boxval">Box text , so it may be that you have the name before type instead of after. Maybe try switching that.

How to replace with   in an html file

I want to replace all the with   in my html file to support XML parser.
But I don't want to replace them directly, I'd like to add an entity in <!DOCTYPE > like below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[<!ENTITY nbsp " ">]>
<html><head></head><body><div>Hello World!</div></body></html>
But when I view the file, there is an extra ]> on the top of the document:
Anyone know how to deal with it?
Thanks!
What you have is a valid way to include an entity declaration in an internal subset. The document is not otherwise valid, though, as you can check with the W3C Markup Validator: the required xmlns attribute on the html element is missing, and so is the required title attribute.
When served as text/html, the document is processed how browsers use to process HTML document, which means among other thing that internal subsets are not recognized; in fact, document type definitions are not read at all – instead, doctype declarations are just taken as magic strings so that some strings trigger “quirks mode”, some don’t. The doctype declaration is parsed in a simplistic manner, which makes the first “>” terminate it, so whatever comes after it is taken as character data.
The morale is that entity declarations just don’t work with “HTML”, internally or externally, when “HTML” means sending something to a browser and telling (in HTTP headers) it to be text/html – and that’s what servers normally tell when they send .html files.
Served as application/xhtml+xml and fixed to conform to XHTML syntax, your approach works on conforming browsers (online demo: http://www.cs.tut.fi/~jkorpela/test/nbsp.xhtml):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
[<!ENTITY nbsp " ">]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Entity demo</title></head>
<body>
<div>Hello World!</div>
</body>
</html>
However, IE 8 and earlier don’t process HTML when served as application/xhtml+xml (the browser just launches a “Save As” dialog).
The conclusions depend on what you are doing and why (and in which sense) you need to “support XML parser”. It’s not really about parsing but about entity declarations. XHTML user agents are not required to understand predefined entities as in HTML (except for those defined in XML), but has this possibility realized somehow? And in general, it is better to convert to actual no-break space characters than to character references.
here
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"[<!ENTITY nbsp " ">

HTML <!doctype html public "">

One of the new doctype declarations can be specified as:
<!doctype html>
But recently I came across one which was slightly different (view source on http://html5boilerplate.com/):
<!doctype html public "">
But I couldn't figure what is it for, public part?
Thanks.
You missed one important character
<!doctype html public "✰">
Inside the quotes is a star character. They like putting it everywhere. Its valid but not in any way useful :P
this is mentioned in the html5boilerplate changelog, do a search for doctype on the page.
Its been done to disable dtd warnings in IDE's like eclipse.
See: Disable DTD warning for Ant scripts in Eclipse?
IE10 needs the PUBLIC "" to properly treat the page as HTML 5 - at least on the Windows 7 version.

autocomplete attribute is not passing XHTML 1.0 Transitional validation, why?

I'm trying to cleanup my xhtml validation -- I'm running my pages through the W3C validator. For some puzzling reason it's not passing on input fields with the autocomplete="off" attribute:
<input name="kwsearch" id="sli_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==this.value) this.value='';"
onblur="if(this.value=='')this.value=this.defaultValue;" class="searchbox" value="Search" />
I'm using this doctype:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
And this is the validation error:
Line 410, Column 81: there is no attribute "autocomplete"
…li_search_1" type="text" autocomplete="off" onfocus="if(this.defaultValue==thi…
I thought this was okay with the W3C -- but, maybe it's still in "submission" phase?
http://www.w3.org/Submission/web-forms2/#autocomplete
Thoughts?
The Web forms specification has nothing to do with HTML 4 / XHTML. Sadly, autocomplete will not pass validation.
I think the only way to achieve valid HTML 4 /XHTML with autocomplete turned off is adding the attribute on page load using JavaScript. Sucks, I know - but I think it's the only way.
autocomplete is a HTML5 attribute, so use a HTML5 document type declaration, if you need it.
That W3C link is for the web forms stuff, not core XHTML. It might be possible to pull in the extra DTD for the web forms and get the page to validate.
If you need autocomplete( browsers do support it ), then try extending your doctype, like in this XHTML 1.1 below:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" [
<!ATTLIST form autocomplete (on|off) #IMPLIED>
]>
I've just banged up against this irritating conflict between browsers and standards. I ended up getting around it by running javascript ON THE PAGE, not waiting for window.onLoad or $(document).ready(), to add the attribute to all elements with the class no-browser-autocomplete. Then i went through my app removing autocomplete="off" and adding this class instead.
Obviously this will fail in browser environments not running javascript.
The reason that i do it on the page, rather than in a dom ready block, is that if you wait for dom ready, the browser's already autocompleted it, at least in Firefox (which i'm testing it in).
So, this is at the start of one of the javascript files i include in my app layout:
//this needs to run BEFORE all of the loaded/ready events fire, that's why it's not in the dom.ready function
$(".no-browser-autocomplete").attr("autocomplete", "off");
$(function(){
//dom ready
});

Remove warning in MyEclipse

How can I modify the conditions for which MyEclipse will throw up warning flags? I'd be happy to hear a generic solution, but here is my specific problem for the curious/if it turns out to be relevant:
<html xmlns="http://www.w3.org/1999/xhtml">
<wicket:panel>
<p>
<object type="text/html" width="750" height="360" wicket:id="htmlRendition"></object>
</wicket:panel>
</html>
causes warnings "Undefined attribute name (xmlns)," "Unknown tag (wicket:panel)" and "Undefined attribute name (wicket:id)." Oddly, there are no errors for most HTML files paired with Wicket Java files, only files with the format ClassName$InnerClassName.html.
I use the following in my HTML files for Wicket:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
I know some IDEs (IntelliJ) for example allow you to register a dtd to validate your xml files. This article looks to apply to XML documents, but perhaps HTML files work or can be configured to work similarly:
http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.wst.xmleditor.doc.user/topics/cxmlcat.html
In the project properties, you can turn off different types of validation. For example, you can say that you don't want DTD validation of XML files, or HTML validation, etc.
Myeclipse example is here.