Elxis CMS Forum
Support => General => Topic started by: xmanhattan on February 09, 2024, 16:52:38
-
Hello all,
This is strange. I created xml forms in two languages and they work fine on my local server as I received no errors.
When I copied them into anyform forms directory on my host and test them, I receive the following error from these sections:
Not acceptable option for field Best time to call!
Not acceptable option for field How did you find us?!
I also validated it online for the xml and it showed it as valid.
English version
<item type="openfieldset" label="Personal Information" />
<item type="text" name="name" label="First name *" required="1" default="{FIRSTNAME}" tip=""></item>
<item type="text" name="surname" label="Last name *" required="1" default="{LASTNAME}" tip=""></item>
<item type="text" name="address" label="Address" default="" tip=""></item>
<item type="text" name="city" label="City" default="" tip=""></item>
<item type="text" name="zip" label="Postal Code" default="" tip=""></item>
<item type="text" name="state" label="State" default="" tip="if applicable"></item>
<item type="country" name="country" label="Country" default="" tip=""></item>
<item type="text" name="phone" label="Telephone" default="" tip=""></item>
<item type="text" name="mobile" label="Mobile" default="" tip=""></item>
<item type="email" name="email" label="E-mail *" required="1" default="{EMAIL}" tip="email address"></item>
<item type="closefieldset" />
<item type="openfieldset" label="Extra Contact Information" />
<item type="select" name="callclient" label="Best time to call" default="" tip="Best time to call, your Local Time?">
<option value="anytime">Anytime</option>
<option value="10:00">10:00</option>
<option value="12:00">12:00</option>
<option value="14:00">14:00</option>
<option value="16:00">16:00</option>
<option value="18:00">18:00</option>
<option value="20:00">20:00</option>
</item>
<item type="checkbox" name="comms" label="Communication methods *" default="2" tip="Methods of communication allowed">
<option value="Telephone">Telephone</option>
<option value="Mobile">Mobile</option>
<option value="Email" checked="checked">Email</option>
<option value="Post">Post</option>
<option value="SMS">SMS</option>
<option value="Video">Video conferencing</option>
</item>
<item type="textarea" name="message" label="Message area to add more info" default="" tip="Additional information">
</item>
<item type="closefieldset" />
Greek version
<item type="openfieldset" label="Επιπλέον πληροφορίες επικοινωνίας" />
<item type="select" name="callclient" label="Η καλύτερη ώρα" default="" tip="Για να σας καλέσουμε, την τοπική σας ώρα.">
<option value="anytime">Οποτεδήποτε</option>
<option value="10:00">10:00</option>
<option value="12:00">12:00</option>
<option value="14:00">14:00</option>
<option value="16:00">16:00</option>
<option value="18:00">18:00</option>
<option value="20:00">20:00</option>
</item>
<item type="checkbox" name="commσ" label="Μεθόδους Επικοινωνίας *" default="2" tip="Σημειώστε αυτά που επιτρέπετε να χρησιμοποιήσουμε.">
<option value="Τηλέφωνο">Τηλέφωνο</option>
<option value="Κινητό">Κινητό</option>
<option value="Email">Email</option>
<option value="Ταχυδρομείο">Ταχυδρομείο</option>
<option value="SMS">SMS</option>
<option value="Video">Τηλεδιάσκεψη</option>
</item>
<item type="textarea" name="Message" label="Μήνυμα" default="" tip="Πρόσθετες πληροφορίες">
</item>
<item type="closefieldset" />
<item type="openfieldset" label="Για Στατιστικούς Σκοπούς" />
<item type="select" name="statistics" label="Πώς μας βρήκατε;" default="0" tip="Βοηθήστε μας να σας βοηθήσουμε καλύτερα.">
<option value="Unanswered">Δεν απαντώ</option>
<option value="Search">Μηχανή αναζήτησης, Google, Bing, κλπ.</option>
<option value="Another">Άλλος Γενεαλόγος</option>
<option value="Friend">Φίλος ενός προηγούμενου πελάτη</option>
<option value="Social">Κοινωνικής δικτύωσης</option>
</item>
<item type="closefieldset" />
And the question is how/why does it work through my wamp server but not on the host?
-
This can be for a couple of reasons such as different php versions and XML settings. However there are issues in your XMLs. As you have only pasted a part of it (I guess the rest of it is OK) I will make notes only on things I see from your post.
A SELECT field may have some options once of which is the pre-selected. Check this:
<item type="select" name="callclient" label="Best time to call" default="" tip="Best time to call, your Local Time?">
<option value="anytime">Anytime</option>
<option value="10:00">10:00</option>
<option value="12:00">12:00</option>
...
</item>
The default value is not one of the SELECT options. Better make it like that: <option value="">Anytime</option>
Similar for the other fields:
<item type="checkbox" name="comms" label="Communication methods *" default="2" tip="Methods of communication allowed">
<option value="Telephone">Telephone</option>
<option value="Mobile">Mobile</option>
<option value="Email" checked="checked">Email</option>
<option value="Post">Post</option>
<option value="SMS">SMS</option>
<option value="Video">Video conferencing</option>
</item>
Tip: provide integers as values, eg:
<option value="1">Telephone</option>
<option value="2">Mobile</option>
When sending submitted forms the plugin will replace the selected option values with the corresponding texts.
Some else that might help for the error is to use CDATA in texts. Example:
<item type="openfieldset" label="<![CDATA[Extra Contact Information]]>" />
An other one: Check if the file's encoding is wrong, for instance it might have been saved as UTF-8 with hidden BOM characters. The correct character encoding is UTF-8 without BOM.
Finally: Use available language strings for the labels and options were possible. For instance instead of this:
<item type="text" name="name" label="First name *" required="1" default="{FIRSTNAME}" tip=""></item>
Use this:
<item type="text" name="name" label="FIRSTNAME" required="1" default="{FIRSTNAME}" tip=""></item>
The minimum available language strings for a plugin are listed in the following files:
Generic language file: languages/en/en.php
Component content: language/en/en.com_content.php
Plugin's (Anyform) language file: components/com_content/plugins/anyform/language/en.plugin_anyform.php
For instance if you use the string "PURPOSE_OF_TRIP" in a label it will be translated automatically to "Purpose of the Trip" (listed in Anyform language file).
-
Hello Datahell,
Yes, you are correct in assuming that the rest of the xml works. I also tested the format using https://codebeautify.org/xmlvalidator (https://codebeautify.org/xmlvalidator) and it is valid even though this is a different situation.
A note for others: the name parameter must be one word no spaces. Also be aware of the ending slash.
I am using php 7.4 on wamp but 8.1 on the host. On 7.4 the following works but on 8.1 it doesn't.
Regarding html theory and select, the https://www.w3schools.com/tags/att_option_selected.asp (https://www.w3schools.com/tags/att_option_selected.asp)
example shows <option value="audi" selected>Audi</option>
so based on this, I assume that the value is what should be in default=
but it does not work in either of the two selects below.
I tested each on the host separately by commenting them as shown in the code below.
I added the choose options to see what would happen but neither one of them worked on the host but it still displayed:
Not acceptable option for field Best time to call, if necessary!
Not acceptable option for field How did you find us?!
I don't know what else to try. I have removed these and the form works.
comment here
<item type="openfieldset" label="Communication Preferences" />
<item type="select" name="callclient" label="Best time to call, if necessary" default="Choose" tip="Best time to call, your Local Time?">
<option value="Choose">Choose</option>
<option value="Anytime">Anytime</option>
<option value="10:00">10:00</option>
<option value="12:00">12:00</option>
<option value="14:00">14:00</option>
<option value="16:00">16:00</option>
<option value="18:00">18:00</option>
<option value="20:00">20:00</option>
</item>
<item type="closefieldset" />
end comment here
comment here
<item type="openfieldset" label="For Statistical Purposes" />
<item type="select" name="statistics" label="How did you find us?" default="xxx" tip="Help us to help you better.">
<option value="xxx">Choose</option>
<option value="Search">Search engine, Google, Bing, etc.</option>
<option value="Social">Social Media</option>
</item>
<item type="closefieldset" />
end comment here
-
It is an XML document, not an HTML document. So, this is wrong for XML:
<option value="audi" selected>Audi</option>
The correct syntax for XML is this:
<option value="audi" selected="selected">Audi</option>
Also on XML single entities should be terminated like this: <item blah="1" blou="2" /> or <item blah="1" blou="2"></item>
Now, You still haven't posted the parsing error. Normally PHP should through an error noting the exact line the problem occurs. Try these:
1. Test it with the sample XML form Anyform has (sample.xml). Is it working with that? If yes, then copy sample.xml and re-create your form based on sample.xml document little by little until you find the problem. If no, then the problem is not on the XML document but on your PHP.
2. Attach here the full XML file you try. I will test it by myself.
-
I made a layout change on the english while testing but both include everything.