Forums

ChronoForms XHTML Validation (Joomfish)

emphaze 23 Feb, 2009
Hello all,

I'm running ChronoForms with Joomfish using this code
<?php
global $mosConfig_lang;
switch ( $mosConfig_lang ) {
  case 'en':
?>
  english form code
<?php
  break;
 
  case 'de':
  default:
?>
  German form code
<?php
  break;
}
?>


The only problem is, that it breaks the XHTML validation, because of the usage of duplicate input names in the code. Is there any way to avoid this ?
Here is the whole code.

<?php
global $mosConfig_lang;
switch ( $mosConfig_lang ) {
  case 'english':
?>
<p class="style1">QUESTIONNAIRE FORM</p>
<div align="justify">zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz<br />
  zzzzzzzzzzzzzzzzzzzz
</div>
<p align="justify">zzzzzzzzzzzzzzzzzzzzzzzzzzzzz</p>
<p align="justify">* Required field</p>
<p>zzzzzzzzzzzzzzzzzzzzzzzzzzzzzz</p>
<table width="93%" border="0">
  <tr valign="top">
    <td width="144" valign="top">Company name *</td>
    <td width="294" valign="top"><input name="companyname" type="text" id="companyname" size="35" maxlength="50" /></td>
    <td width="207" valign="top">Address *</td>
    <td width="400" valign="top"><input name="address" type="text" id="address" size="35" maxlength="70" /></td>
  </tr>
  <tr valign="top">
    <td valign="top">City *</td>
    <td valign="top"><input name="city" type="text" id="city" size="35" maxlength="50" /></td>
    <td valign="top">Country *</td>
    <td valign="top"><input name="country" type="text" id="country" size="35" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="144" valign="top">Phone/Fax *</td>
    <td valign="top"><input name="phonefax" type="text" id="phonefax" size="35" maxlength="50" /></td>
    <td valign="top">E-mail *</td>
    <td valign="top"><input name="email" type="text" id="email" size="35" maxlength="50" /></td>
  </tr>
  <tr>
    <td valign="top">Website</td>
    <td valign="top"><label></label>
        <input name="website" type="text" id="website" size="35" maxlength="50" /></td>
    <td valign="top">Contact person *</td>
    <td valign="top"><label>
      <input name="contactperson" type="text" id="contactperson" size="35" maxlength="50" />
    </label></td>
  </tr>
  <tr>
    <td valign="top"> </td>
    <td valign="top"> </td>
    <td valign="top"> </td>
    <td valign="top"> </td>
  </tr>
  <tr>
    <td colspan="2" valign="top">xxxxxxxxxxxxx</td>
    <td colspan="2" valign="top">xxxxxxxxxxxxx</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="product" cols="35" rows="4" id="product"></textarea></td>
    <td colspan="2" valign="top"><textarea name="mix" cols="35" rows="4" id="mix"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxxxxxx</td>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxxxxxx</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="proportion" cols="35" rows="4" id="proportion"></textarea></td>
    <td colspan="2" valign="top"><textarea name="shape" cols="35" rows="4" id="shape"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxx</td>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxxxxx</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="weight" cols="35" rows="4" id="weight"></textarea></td>
    <td colspan="2" valign="top"><textarea name="speed" cols="35" rows="4" id="speed"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxxxxxx</td>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxxxx</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="material" cols="35" rows="4" id="material"></textarea></td>
    <td colspan="2" valign="top"><textarea name="specifics" cols="35" rows="4" id="specifics"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">xxxxxxxxxxxxx</td>
    <td colspan="2" valign="top">xxxxxxxxxxxxxxxxx</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><p>
      <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
    </p>
      <p>
        <input type="submit" name="submit" id="submit" value="Submit" />
        <input type="reset" name="reset" id="reset" value="Reset" />
    </p></td>
    <td colspan="2" valign="top">
              <p>
          <input name="image1" type="file" id="image1" />
        </p>
        <p>
          <input name="image2" type="file" id="image2" />
        </p>
        <p>jpg, png, bmp, gif, doc, txt, rtf, sxw, pdf, rar, zip formats are allowed 2048 Kb max</p>        </td>
  </tr>
  <tr>
    <td valign="top"> </td>
    <td colspan="3" valign="top"> </td>
  </tr>
</table>   
<?php
  break;

  case 'bulgarian':
  default:
?>
  <p class="style1">КАСИ ТЕМПРА ПАК - ВЪПРОСНИК</p>
<div align="justify">За запитвания относно машините предлагани от фирмата, моля попълнете този въпросник. Целта на тази форма е да ни помогне най-точно и бързо да идентифицираме Вашите нужди и да Ви подготвим конкретна оферта. Поради тази причина Ви молим да попълните възможно най-много полета. В случай, че имате въпроси относно формата, моля свържете се с нас за допълнителни разяснения.<br />
</div>
<p align="justify">От съображения за сигурност <span class="style2">използването на ( / ) при попълване на формата е забранено.</span> ПРИМЕР: Можете да добавите интернет страницата си като <span class="style2">www.website.com или website.com,</span> <span class="style2">но не и като http://www.website.com</span>. Благодарим Ви.</p>
<p align="justify">* Задължително поле</p>
<p>Също така, можете да изтеглите формата от <a href="http://www.kt-pack.com/drac/ktpack-form.doc">тук</a> и да я изпратите на office@kt-pack.com или на факс 00359 618 607 63.</p>
<table width="93%" border="0">
  <tr valign="top">
    <td width="144" valign="top">Фирма *</td>
    <td width="294" valign="top"><input name="companyname" type="text" id="companyname" size="35" maxlength="50" /></td>
    <td width="207" valign="top">Адрес *</td>
    <td width="400" valign="top"><input name="address" type="text" id="address" size="35" maxlength="70" /></td>
  </tr>
  <tr valign="top">
    <td valign="top">Град *</td>
    <td valign="top"><input name="city" type="text" id="city" size="35" maxlength="50" /></td>
    <td valign="top">Страна *</td>
    <td valign="top"><input name="country" type="text" id="country" size="35" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="144" valign="top">Тел./Факс *</td>
    <td valign="top"><input name="phonefax" type="text" id="phonefax" size="35" maxlength="50" /></td>
    <td valign="top">Ел. поща *</td>
    <td valign="top"><input name="email" type="text" id="email" size="35" maxlength="50" /></td>
  </tr>
  <tr>
    <td valign="top">Уебсайт</td>
    <td valign="top"><label></label>
        <input name="website" type="text" id="website" size="35" maxlength="50" /></td>
    <td valign="top">Лице за контакт *</td>
    <td valign="top"><label>
      <input name="contactperson" type="text" id="contactperson" size="35" maxlength="50" />
    </label></td>
  </tr>
  <tr>
    <td valign="top"> </td>
    <td valign="top"> </td>
    <td valign="top"> </td>
    <td valign="top"> </td>
  </tr>
  <tr>
    <td colspan="2" valign="top">Какъв е вида продукта (продуктите) ?</td>
    <td colspan="2" valign="top">Еднороден продукт или пропорционална смес от няколко продукта ?</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="product" cols="35" rows="4" id="product"></textarea></td>
    <td colspan="2" valign="top"><textarea name="mix" cols="35" rows="4" id="mix"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">Какво е съотношенението на продуктите (ако е приложимо) ?</td>
    <td colspan="2" valign="top">Каква е формата на желаните опаковки  ?</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="proportion" cols="35" rows="4" id="proportion"></textarea></td>
    <td colspan="2" valign="top"><textarea name="shape" cols="35" rows="4" id="shape"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">Колко грама (мл.) в една опаковка ?</td>
    <td colspan="2" valign="top">Каква производителност ви е необходима (опаковки / час) ?</td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="weight" cols="35" rows="4" id="weight"></textarea></td>
    <td colspan="2" valign="top"><textarea name="speed" cols="35" rows="4" id="speed"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">Какъв е материалът за опаковката ?</td>
    <td colspan="2" valign="top">Има ли нещо специфично, което трябва да знаем за вашият продукт ? </td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><textarea name="material" cols="35" rows="4" id="material"></textarea></td>
    <td colspan="2" valign="top"><textarea name="specifics" cols="35" rows="4" id="specifics"></textarea></td>
  </tr>
  <tr>
    <td colspan="2" valign="top">Други бележки</td>
    <td colspan="2" valign="top">Снимки на продукта / Качване на файлове : </td>
  </tr>
  <tr>
    <td colspan="2" valign="top"><p>
      <textarea name="comments" cols="35" rows="4" id="comments"></textarea>
    </p>
      <p>
        <input type="submit" name="submit" id="submit" value="Submit" />
        <input type="reset" name="reset" id="reset" value="Reset" />
    </p></td>
    <td colspan="2" valign="top">
              <p>
          <input name="image1" type="file" id="image1" />
        </p>
        <p>
          <input name="image2" type="file" id="image2" />
        </p>
        <p>jpg, png, bmp, gif, doc, txt, rtf, sxw, pdf, rar, zip формати са позволени 2048 Kb max</p>        </td>
  </tr>
  <tr>
    <td valign="top"> </td>
    <td colspan="3" valign="top"> </td>
  </tr>
</table>
<?php
  break;
}
?>


Changing the input names will require a new fields in the sql table and some form "language aware" email for results to be send, which makes the form too complicated when using 5 or 6 languages.
Any ideas would be apreciated. Thank you in advance !
GreyHead 23 Feb, 2009
Hi emphaze,

I don't understand this. In the Form HTML produced there will only be one langauge OR the other - so there won't be any duplicated input names in the page source.

Can you point us to a page with the problem to look at?

Bob
emphaze 24 Feb, 2009
Hi Bob and thank you for your attention ! I've noticed, that XHTML validation ONLY fails on the required fields, when chronoform validation is ON. Here is the output from W3.

Error Line 152, Column 82: duplicate specification of attribute "class".

…"companyname" class="required" class="required" type="text" id="companyname"

You have specified an attribute more than once. Example: Using the "height" attribute twice on the same "img" tag.


Error Line 154, Column 78: duplicate specification of attribute "class".

…ame="address" class="required" class="required" type="text" id="address" size

You have specified an attribute more than once. Example: Using the "height" attribute twice on the same "img" tag.


Error Line 152, Column > 80: XML Parsing Error: Attribute class redefined.

…e="companyname" class="required" class="required" type="text" id="companyname…



Error Line 154, Column > 80: XML Parsing Error: Attribute class redefined.

…e="address" class="required" class="required" type="text" id="address" size="…


Am I doing something the wrong way ? Any ideas for workaround ?
GreyHead 24 Feb, 2009
Hi emphaze,

I haven't tested this but I'd guess that you have the validation classes added manually in the Form HTML AND you have the same fields in the field list on the Validation Tab. If I'm correct you only need one or the other.

Bob
emphaze 24 Feb, 2009
Hi Bob,

I don't have class=required statements added manually in the HTML code. I think that this is happening, because of the multilingual form I'm using and "case" statement. The English and Russian form code is the same and the only difference is the text language. Practically, I have the same code twice - one time for case 'en' and one time for case 'ru'. ChronoForms reads the whole code and adds class:required statements to these fields defined in the Validation tab in ChronoForms control panel, thus breaking the XHTML validation.
GreyHead 24 Feb, 2009
Hi emphaze,

I don't think that works. In each case the actual html shown on the page will only have one language OR the other. So each input only appears once. And I believe that ChronoForms adds the validation classes after the PHP eval has run.

I'd need to run some tests on this to try and see what is happening.

Bob
Max_admin 24 Feb, 2009
Hi Bob, emphaze,

ChronoForms adds the validation classes after the PHP eval has run.



Exactly, its added using the domready mootools event and so after the page is loaded and only the PHP output exists!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
emphaze 26 Feb, 2009
Hi admin, Bob
I agree with that and the XHTML validation output shows it, but this is the code generated:
# <table width="93%" border="0">
# <tr valign="top">
# <td width="144" valign="top">Company name *</td>
# <td width="294" valign="top"><input name="companyname" class="required" class="required" type="text" id="companyname" size="35" maxlength="50" /></td>


And this is the code from my form template:
<table width="93%" border="0">
  <tr valign="top">
    <td width="144" valign="top">Company name *</td>
    <td width="294" valign="top"><input name="companyname" type="text" id="companyname" size="35" maxlength="50" /></td>


Why is added twice ?!?!

Here are my settings from Validation Tab:
Enable validation: Yes
Validation type: mootools
Required: companyname,address,contactperson,country,phonefax,city,email
Email: email

Please help.

EDIT: I found a workaround by leaving the validation on and adding the "required" classes manually, thus avoiding the duplicate entries. However, I'm still interested why this happens. Is it a bug or I'm missing something ?
Max_admin 26 Feb, 2009
Hi emphaze,

there was some misunderstanding, I thought the problem is with duplicate HTML elements and not classes!

Cheers
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.