24 replies [Last post]
apeee's picture
Offline
Joined: 12/11/2007
Juice: 128
Was this information Helpful?

I found that the main page of your livetest website at http://livetest.ubercart.org/ does validate but inner product page does not validate XHTML. Can it show green bar when validating through validator.w3.org

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Making Valid XHTML Strict

Can you list up here the errors you were getting? Smiling

apeee's picture
Offline
Joined: 12/11/2007
Juice: 128
Re: Re: Making Valid XHTML Strict

From, http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Flivetest.uberca...

there is no attribute "nowrap" ---> th nowrap="nowrap">Add to cart

and

there is no attribute "width" ---> td width="100%"

and

ID "edit-submit" already defined ---> input type="submit" name="op" id="edit-submit" value="Add to cart" class="form

and

ID "edit-nid" already defined ----> input type="hidden" name="nid" id="edit-nid" value="5"

you need to remove nowrap and width from the above and I think defining add to cart/submit buttons with "class" rather than "id" can solve the problem.

These are the main problem. I think if these are sorted out all the inner product pages will start to valid xhtml.

partyman's picture
Offline
Joined: 10/18/2008
Juice: 23
Making Valid XHTML Strict

Were the problems identifed at post above resolved? I can't validate...

(Quote..)

From, http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Flivetest.uberca...

there is no attribute "nowrap" ---> th nowrap="nowrap">Add to cart

and

there is no attribute "width" ---> td width="100%"

and

ID "edit-submit" already defined ---> input type="submit" name="op" id="edit-submit" value="Add to cart" class="form

and

ID "edit-nid" already defined ----> input type="hidden" name="nid" id="edit-nid" value="5"

you need to remove nowrap and width from the above and I think defining add to cart/submit buttons with "class" rather than "id" can solve the problem.

These are the main problem. I think if these are sorted out all the inner product pages will start to valid xhtml.
(End quote)

Gergely Varga's picture
Offline
Joined: 03/05/2008
Juice: 51
Submit button Validation error

Line 156, Column 35: ID "edit-submit" already defined.

input type="submit" name="op" id="edit-submit" value="Add to cart" class="form

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

--
The problem is that every "add to cart" and "edit-qty" submit button has the same id
any suggestions?

Thanks!

I really like lemonade.
42droids.co.uk

acdtrp's picture
Offline
Joined: 03/16/2008
Juice: 59
Re: Submit button Validation error

This is a big problem for me too, because I would like every page of my site to validate and still I would like to have "add to cart" button and "quantity" field on my product page. If i remove them everything validates okay.

Also I noticed a bug in the uc_catalog.module - on line 1145 we have

"$product_table .= '</td>';"

but it should be after the else closure, just move it two lines below and place it on line 1147.

acdtrp's picture
Offline
Joined: 03/16/2008
Juice: 59
Re: Re: Submit button Validation error

Finally I have managed to validate my product page with the quantity fields and submit buttons on it. What I did was to edit the the includes/form.inc file and generate a random number before each ID and added to it for text fields and buttons. After that I have removed the ID reference from the labels above because they generated warnings (not errors but still unsatisfying) about non-existent ID's. Now I have to do heavy testing to see if this messed up with something else. If you have done that 'random-id' thing before and saw some negative effects, please share.

acdtrp's picture
Offline
Joined: 03/16/2008
Juice: 59
Re: Re: Re: Submit button Validation error

The first problem after editing the Form API file i noticed is that the expandable areas in edit node for example stopped expanding because of the messed up reference between the label and the area. Any ideas?

txcrew's picture
Offline
Joined: 09/28/2007
Juice: 103
Re: Re: Re: Re: Submit button Validation error

I'm working on fixing the same thing on my site.

Couldn't you just change the ID's to classes?

txcrew

EDIT: Sorry I didn't see that it was Drupal core files and not ubercart core files. I think I answered my own question.

scottrigby's picture
Offline
Getting busy with the Ubercode.
Joined: 10/08/2007
Juice: 121
Hi txcrew, I don't

Hi txcrew,

I don't understand – why can't classes be substituted for IDs?

Or how about the suggestion to append the "edit-submit" with a number – like Node ID? 'edit-submit'.$node->nid ... that way if they need to be IDs, they'd all be unique, and predictable (in case that's important)?

TR
TR's picture
Offline
Bug FinderFAQ ModeratorGetting busy with the Ubercode.
Joined: 11/05/2007
Juice: 3424
scottrigby wrote:I don't
scottrigby wrote:

I don't understand – why can't classes be substituted for IDs?

Because this is not something that's wrong with Ubercart - it's a problem with *Drupal*. The fix would have to be made in Drupal core. You're welcome to push the issue on drupal.org to try to get a fix into Drupal 5.x, but I doubt there will be another release of Drupal 5.x just to fix bugs like this. I believe this particular issue is resolved in Drupal 6.x, but I haven't verified that myself.

If it's a big problem for you, you could always hack Drupal core like acdtrp did by modifying includes/form.inc. That would be the appropriate place to look to change the ids to classes. Be aware that in doing this you might break some jQuery code in Drupal, Ubercart and other modules if it selects based on id, and you might have to change some of the css generated by Drupal, Ubercart, and your theme. acdtrp mentioned that became a problem when he modified the core...

<tr>.
pasqualle@drupal.org's picture
Offline
Joined: 12/02/2007
Juice: 31
edit-submit

the "edit-submit" problem is fixed in Drupal 6
http://drupal.org/node/111719

and the workaround in Drupal 5
http://drupal.org/node/269869

scottrigby's picture
Offline
Getting busy with the Ubercode.
Joined: 10/08/2007
Juice: 121
Re: edit-submit

can a similar solution be used for the edit-qty issue?

From w3 validator:

Line 160, Column 41: ID "edit-qty" already defined.
<div><input type="hidden" name="qty" id="edit-qty" value="1"  />
An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).
sign's picture
Offline
Joined: 08/24/2008
Juice: 2
<?phpfunction
<?php
function phptemplate_hidden($element) {
  static
$dupe_ids = array();
  if (isset(
$dupe_ids[$element['#id']])) {
   
$dupe_ids[$element['#id']]++;
   
$element['#id'] = $element['#id'] .'-'. $dupe_ids[$element['#id']];
  }
  else {
   
$dupe_ids[$element['#id']] = 0;
  }
  return
'<input type="hidden" name="'. $element['#name'] . '" id="'. $element['#id'] . '" value="'. check_plain($element['#value']) ."\" " . drupal_attributes($element['#attributes']) ." />\n";
}
?>
rhrueda's picture
Offline
Joined: 10/23/2008
Juice: 6
Re: <?phpfunction

can a similar solution be used for the "imceimage-field_logo-" issue?
It happens when I have a view with more than I content that have an imceimage cck field.

From w3 validator:

Line 96, Column 129: ID "imceimage-field_logo-" already defined.
…" alt="" width="200" height="80" id="imceimage-field_logo-" /></a>

An "id" is a unique identifier. Each time this attribute is used in a document it must have a different value. If you are using this attribute as a hook for style sheets it may be more appropriate to use classes (which group elements) than id (which are used to identify exactly one element).

Thanks!!

AttachmentSize
capture.JPG 32.55 KB
validation.JPG 34.24 KB
scottrigby's picture
Offline
Getting busy with the Ubercode.
Joined: 10/08/2007
Juice: 121
this is important :)

html valid sites should be able to happen with ubercart – my sites are otherwise fully valid, except for the pages where products are listed as teasers... same errors as above

Thanks in advance for help with this! (a patch would be great!)

Smiling Scott

zmove's picture
Offline
Bug FinderEarly adopter... addicted to alphas.Getting busy with the Ubercode.Internationalizationizer
Joined: 08/13/2007
Juice: 1192
+1 Ubercart need, at least

+1

Ubercart need, at least for 2.x, to remove all the inline CSS, table align property and others non W3C friendly stuff that make the work of designer so hard sometimes. Smiling

rhrueda's picture
Offline
Joined: 10/23/2008
Juice: 6
Re: Making Valid XHTML Strict

nobody?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Making Valid XHTML Strict

I'm not even sure how your problem is related to Ubercart. IMCE has nothing to do with us. Puzzled

rhrueda's picture
Offline
Joined: 10/23/2008
Juice: 6
Re: Re: Re: Making Valid XHTML Strict

It isn't related! But this is one of the few sites were this issue is comented, so I posted here trying to resolve my problem with drupal&imce.

Thanks anyway.

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: Re: Re: Re: Making Valid XHTML Strict

hehe I gotcha. No problem, I just couldn't figure out which module we had that was making IDs like that. Laughing out loud

scottrigby's picture
Offline
Getting busy with the Ubercode.
Joined: 10/08/2007
Juice: 121
edit-qty issue?

but the edit-qty issue is an ubercart issue, right?

Ryan's picture
Offline
Joined: 08/07/2007
Juice: 15438
Re: edit-qty issue?

Not really... this is more an issue with Drupal's Forms API. It's my understanding that work has already been done to address issues like this, but I could be mistaken. Puzzled

scottrigby's picture
Offline
Getting busy with the Ubercode.
Joined: 10/08/2007
Juice: 121
Re: Re: edit-qty issue?

I see - have you experienced this problem Ryan? For example, say you have a view that shows a list of products - this has been an issue for all our D5 sites. I haven't been following this issue in D6 because I've only had a problem with this in relation to showing a lit of products through uc (and that's only for D5 still, right?). Smiling

Arakrys's picture
Offline
Joined: 10/03/2008
Juice: 11
Re: Making Valid XHTML Strict

For the id="edit-qty" when using the add-to-cart hook I added this within the loop for each product:

$counter++; // was already in my loop
$add_to_cart=theme('uc_product_add_to_cart', $node);
$add_to_cart = preg_replace("/edit-qty/","edit-qty{$counter}", $add_to_cart);

This ensures the label has the same id, and prevents the rare and unexpected but non-perfect double random number (there's also a uniq-id function somewhere).

I'm too n00b with Drupal to be able to tell where to build this in for the default list.