stefangabos / Zebra_Form

A jQuery augmented PHP library for creating secure HTML forms and validating them easily
Other
98 stars 49 forks source link

Zebra_Form CSS class not added to the form #34

Open vhotspur opened 7 years ago

vhotspur commented 7 years ago

When running the example, the form is not styled, JavaScript validation does not work.

I think the culprit is in the initialization of the Zebra_Form class where $attributes are (by default) initialized to an empty string instead of an empty array. Consequent adding of the Zebra_Form CSS class (in render()) thus does not modify the array as intended.

I think this is related to upgrade to PHP 7 as I have not seen this behaviour several month ago.

Anyway, for me the following patch worked:

--- a/Zebra_Form.php
+++ b/Zebra_Form.php
@@ -163,7 +163,7 @@ class Zebra_Form
      *
      *  @return void
      */
-    function __construct($name, $method = 'POST', $action = '', $attributes = '')
+    function __construct($name, $method = 'POST', $action = '', $attributes = [])
     {

         $this->controls = $this->variables = $this->errors = $this->master_labels = array();