Skip to content

Commit

Permalink
Prevent invalid element name (#12954)
Browse files Browse the repository at this point in the history
* Prevent invalid element name

Prevent create form element with empty name value like ''

* trim name

* Update element.zep

* Update element.zep
  • Loading branch information
emiliodeg authored and sergeyklay committed Aug 6, 2017
1 parent cc2aff1 commit b76284f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions phalcon/forms/element.zep
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ abstract class Element implements ElementInterface
*/
public function __construct(string name, var attributes = null)
{
let name = trim(name);

if empty name {
throw new \InvalidArgumentException("Form element name is required");
}

let this->_name = name;
if typeof attributes == "array" {
let this->_attributes = attributes;
Expand Down

0 comments on commit b76284f

Please sign in to comment.