Skip to content

Commit

Permalink
Change novalidate to browser_validate and swap logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Bloke committed May 24, 2016
1 parent fe95e6a commit d0f4869
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions README.textile
Expand Up @@ -61,7 +61,7 @@ If upgrading from v4.0.3.20, please note these differences:
* Disable or remove the zem_contact_lang plugin. Language strings are now bundled as part of the plugin itself. If you have a translation Textpack available that is not yet bundled, please submit it for inclusion.
* Classes based on the input element @name@ are no longer automatically applied. Only default class names beginning with @zem@ are set. To employ custom classses, use the @class@ attribute for each tag, or the global @classes@ attribute to set nanes for error and information messages.
* If your site's Doctype preference is set to @html5@ you may use HTML5 attributes in your tags. Otherwise, they will be ignored.
* Validation of required elements and min/max constraints is done by the browser first, and the plugin second. So if you specify a field is required and it is left empty, the browser will usually prevent the form being submitted. To bypass (most of) the browser checks, specify @novalidate="1"@ in your @<txp:zem_contact />@ tag.
* Validation of required elements and min/max constraints is done by the browser first, and the plugin second. So if you specify a field is required and it is left empty, the browser will usually prevent the form being submitted. To bypass (most of) the browser checks, specify @browser_validate="0"@ in your @<txp:zem_contact />@ tag.

h2(#usage). Usage

Expand Down Expand Up @@ -152,7 +152,7 @@ h4. Attributes
* @from_form="form name"@<br />Use specified form (overrides @from@ attribute).
* @label="text"@<br />Label for the contact form. If set to an empty string, display of the fieldset and legend tags will be suppressed. Default is @Contact@.
* @lang="lang-code"@<br />Override the language strings that would normally be used from the current admin-side language in force. e.g. @lang="fr-fr"@ would load the French language strings. A Textpack must already exist for the chosen language.
* @novalidate="boolean"@<br />Set to 1 if you wish to prevent the browser from validating form field values and the required status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @0@.
* @browser_validate="boolean"@<br />Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@.
* @redirect="URL"@<br />Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@.
* @required="boolean"@<br />Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@.
* @send_article="boolean"@<br />Whether to use this form to send an article. Available values: @1@ (yes) or @0@ (no). Default is @0@.
Expand Down
48 changes: 24 additions & 24 deletions zem_contact_reborn.php
Expand Up @@ -238,27 +238,27 @@ function zem_contact($atts, $thing = null)
$zem_contact_form, $zem_contact_labels, $zem_contact_values;

extract(zem_contact_lAtts(array(
'body_form' => '',
'class' => 'zemContactForm',
'classes' => '',
'copysender' => 0,
'expire' => 600,
'form' => '',
'from' => '',
'from_form' => '',
'label' => null,
'novalidate' => 0,
'redirect' => '',
'required' => '1',
'show_error' => 1,
'show_input' => 1,
'send_article' => 0,
'subject' => null,
'subject_form' => '',
'to' => '',
'to_form' => '',
'thanks' => null,
'thanks_form' => ''
'body_form' => '',
'class' => 'zemContactForm',
'classes' => '',
'copysender' => 0,
'expire' => 600,
'form' => '',
'from' => '',
'from_form' => '',
'label' => null,
'browser_validate' => 1,
'redirect' => '',
'required' => '1',
'show_error' => 1,
'show_input' => 1,
'send_article' => 0,
'subject' => null,
'subject_form' => '',
'to' => '',
'to_form' => '',
'thanks' => null,
'thanks_form' => ''
), $atts));

if (!empty($lang)) {
Expand Down Expand Up @@ -539,7 +539,7 @@ function zem_contact($atts, $thing = null)
if ($show_input && !$send_article || gps('zem_contact_send_article')) {
$out = '<form method="post"' . ((!$show_error && $zem_contact_error) ? '' : ' id="zcr' . $zem_contact_form_id . '"') .
($class ? ' class="' . $class . '"' : '') .
($novalidate ? ' novalidate' : '') .
($browser_validate ? '' : ' novalidate') .
' action="' . txpspecialchars(serverSet('REQUEST_URI')) . '#zcr' . $zem_contact_form_id . '">' .
($label ? n . '<fieldset>' : n . '<div>') .
($label ? n . '<legend>' . txpspecialchars($label) . '</legend>' : '') .
Expand Down Expand Up @@ -1948,7 +1948,7 @@ function zem_contact_if($atts, $thing = null)
* Disable or remove the zem_contact_lang plugin. Language strings are now bundled as part of the plugin itself. If you have a translation Textpack available that is not yet bundled, please submit it for inclusion.
* Classes based on the input element @name@ are no longer automatically applied. Only default class names beginning with @zem@ are set. To employ custom classses, use the @class@ attribute for each tag, or the global @classes@ attribute to set nanes for error and information messages.
* If your site's Doctype preference is set to @html5@ you may use HTML5 attributes in your tags. Otherwise, they will be ignored.
* Validation of required elements and min/max constraints is done by the browser first, and the plugin second. So if you specify a field is required and it is left empty, the browser will usually prevent the form being submitted. To bypass (most of) the browser checks, specify @novalidate="1"@ in your @<txp:zem_contact />@ tag.
* Validation of required elements and min/max constraints is done by the browser first, and the plugin second. So if you specify a field is required and it is left empty, the browser will usually prevent the form being submitted. To bypass (most of) the browser checks, specify @browser_validate="0"@ in your @<txp:zem_contact />@ tag.
h2(#usage). Usage
Expand Down Expand Up @@ -2039,7 +2039,7 @@ function zem_contact_if($atts, $thing = null)
* @from_form="form name"@<br />Use specified form (overrides @from@ attribute).
* @label="text"@<br />Label for the contact form. If set to an empty string, display of the fieldset and legend tags will be suppressed. Default is @Contact@.
* @lang="lang-code"@<br />Override the language strings that would normally be used from the current admin-side language in force. e.g. @lang="fr-fr"@ would load the French language strings. A Textpack must already exist for the chosen language.
* @novalidate="boolean"@<br />Set to 1 if you wish to prevent the browser from validating form field values and the required status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @0@.
* @browser_validate="boolean"@<br />Set to 0 if you wish to stop the browser from validating form field values and 'required' status of input elements. The plugin itself is then solely responsible for validation and will indicate error conditions after submission. Default is @1@.
* @redirect="URL"@<br />Redirect to specified URL (overrides @thanks@ and @thanks_form@ attributes). URL must be relative to the Textpattern site URL. Example: @redirect="monkey"@ would redirect to @http://example.com/monkey@.
* @required="boolean"@<br />Whether to require all tags in this contact form to be completed before the form can be submitted. Can be overridden on a field-by-field basis by using the @required@ attribute in the relevant tag. Available values: @1@ (yes) or @0@ (no). Default is @1@.
* @send_article="boolean"@<br />Whether to use this form to send an article. Available values: @1@ (yes) or @0@ (no). Default is @0@.
Expand Down

0 comments on commit d0f4869

Please sign in to comment.