I've discovered an issue with field names in form elements that contain hyphens.
The symptoms:
[list]
A form is set with a field name containing a hypen (e.g. "first-name").
The DB Save action is used within an event following submission.
Upon submission of form data of a published form, there is a PHP error referencing an unexpected "-" in /administrator/components/com_chronoforms/form_actions/db_save/db_save.php [/list]
The problem:
While HTML and MySQL will both allow a hypen (-) as part of a valid field name for a data table, Chronoforms users will experience a PHP error during attempts to save to the database. This is due to the building of class variables in /administrator/components/com_chronoforms/form_actions/db_save/db_save.php on line 34 which places the hyphen as part of a variable—something that is illegal in PHP syntax. So, for example, using the value "first-name" as a field name on a Chronoforms element will generate "var $first-name" when that PHP routine is called.
Proposed solutions:
[list=ordered]
Warn administrators that hyphens are invalid characters for field names upon the creation of a field element. This is an easily-implemented and understood rule, though it does have the drawback of limiting what would otherwise be a valid field name.
Change the structure of /administrator/components/com_chronoforms/form_actions/db_save/db_save.php to handle the variables as an array of objects, into which each would contain a field_name value, rather than as the name of class variables. This may be a major change to the design, though it offers the greatest flexibility between both HTML element names and corresponding MySQL database field names. [/list:o]
The symptoms:
[list]
The problem:
While HTML and MySQL will both allow a hypen (-) as part of a valid field name for a data table, Chronoforms users will experience a PHP error during attempts to save to the database. This is due to the building of class variables in /administrator/components/com_chronoforms/form_actions/db_save/db_save.php on line 34 which places the hyphen as part of a variable—something that is illegal in PHP syntax. So, for example, using the value "first-name" as a field name on a Chronoforms element will generate "var $first-name" when that PHP routine is called.
Proposed solutions:
[list=ordered]