{"action":"opened","issue":{"url":"https://api.github.com/repos/zencart/zencart/issues/1078","repository_url":"https://api.github.com/repos/zencart/zencart","labels_url":"https://api.github.com/repos/zencart/zencart/issues/1078/labels{/name}","comments_url":"https://api.github.com/repos/zencart/zencart/issues/1078/comments","events_url":"https://api.github.com/repos/zencart/zencart/issues/1078/events","html_url":"https://github.com/zencart/zencart/issues/1078","id":164319152,"number":1078,"title":"Validation of forms in admin LEAD pages.","user":{"login":"zcwilt","id":227354,"avatar_url":"https://avatars.githubusercontent.com/u/227354?v=3","gravatar_id":"","url":"https://api.github.com/users/zcwilt","html_url":"https://github.com/zcwilt","followers_url":"https://api.github.com/users/zcwilt/followers","following_url":"https://api.github.com/users/zcwilt/following{/other_user}","gists_url":"https://api.github.com/users/zcwilt/gists{/gist_id}","starred_url":"https://api.github.com/users/zcwilt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zcwilt/subscriptions","organizations_url":"https://api.github.com/users/zcwilt/orgs","repos_url":"https://api.github.com/users/zcwilt/repos","events_url":"https://api.github.com/users/zcwilt/events{/privacy}","received_events_url":"https://api.github.com/users/zcwilt/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-07T14:14:14Z","updated_at":"2016-07-07T14:14:14Z","closed_at":null,"body":"Currently apart from the admin/users page, none of the LEAD pages that allow for add/edit do any validation of the forms. (apart from maybe some `required` processing) \r\n\r\nValidation can have 3 parts \r\n\r\n  1.  Use of CSS3 pattern attribute and required attribute\r\n  2.  Use of javascript validation on form submit \r\n  3.  fallback validation using PHP \r\n\r\nLEAD code currently allows for 1 and 3 at the moment, however because validations are defined in an array, \r\nthis should allow for common javascript to validate entries as well. \r\n\r\nThe format for defining validations is currently to add an entry to a `fields` definition \r\n\r\ne.g .\r\n\r\n                'admin_name' => array(\r\n                    'bindVarsType' => 'string',\r\n                    'layout' => array(\r\n                        'common' => array(\r\n                            'title' => TEXT_ENTRY_ADMIN_NAME,\r\n                            'align' => 'right',\r\n                            'type' => 'text',\r\n                            'size' => '10'\r\n                        )\r\n                    ),\r\n                    'validations' => array(\r\n                        'required' => true,\r\n                        'pattern' => 'somecss3validationpattern',\r\n                        'rules' => array(\r\n                            array('type' => 'lengthBetween', 'params'=>array(4,12))\r\n                        )\r\n                    )\r\n\r\nThe structure still needs some work in terms of defining custom error messages, however I think my biggest problem is that having to define validations per field bloats the definition array and it may be better to have a top level validations array \r\ne.g. \r\n\r\n                'validations' => array(\r\n                    'admin_name' = array (\r\n                        'required' => true,\r\n                        'pattern' => 'somecss3validationpattern',\r\n                        'rules' => array(\r\n                            array('type' => 'lengthBetween', 'params'=>array(4,12))\r\n                        )\r\n                    ),\r\n                    'admin_email' => array (\r\n                        'required' => true,\r\n                          'rules' => array(\r\n                                array('type' => 'email')\r\n                            )\r\n                        }\r\n                    )\r\n"}}
{"actor":{"display_login":"zcwilt"}}