{"action":"opened","number":457,"pull_request":{"url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457","id":50470670,"html_url":"https://github.com/XOOPS/XoopsCore/pull/457","diff_url":"https://github.com/XOOPS/XoopsCore/pull/457.diff","patch_url":"https://github.com/XOOPS/XoopsCore/pull/457.patch","issue_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/457","number":457,"state":"open","locked":false,"title":"Enhanced form element specification","user":{"login":"geekwright","id":3181636,"avatar_url":"https://avatars.githubusercontent.com/u/3181636?v=3","gravatar_id":"","url":"https://api.github.com/users/geekwright","html_url":"https://github.com/geekwright","followers_url":"https://api.github.com/users/geekwright/followers","following_url":"https://api.github.com/users/geekwright/following{/other_user}","gists_url":"https://api.github.com/users/geekwright/gists{/gist_id}","starred_url":"https://api.github.com/users/geekwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geekwright/subscriptions","organizations_url":"https://api.github.com/users/geekwright/orgs","repos_url":"https://api.github.com/users/geekwright/repos","events_url":"https://api.github.com/users/geekwright/events{/privacy}","received_events_url":"https://api.github.com/users/geekwright/received_events","type":"User","site_admin":false},"body":"Re: #453 \r\n\r\n\r\nAll aspects of an element can be specified in one invocation. Consider this common scenario:\r\n```\r\n$buttonCancel = new Xoops\\Form\\Button('', 'cancel', XoopsLocale::A_CANCEL, 'button');\r\n$buttonCancel->setExtra(\"onclick='javascript:history.go(-1);'\");\r\n$buttonCancel->setClass('btn btn-danger');\r\n$buttonTray->addElement($buttonCancel);\r\n```\r\nThis can all be accomplished with one call:\r\n```\r\nnew Xoops\\Form\\Button([\r\n    'name' => 'cancel',\r\n    'value' => XoopsLocale::A_CANCEL,\r\n    'type' => 'button',\r\n    'class' => 'btn btn-danger',\r\n    'onclick' => 'javascript:history.go(-1);',\r\n    ':form' => $buttonTray,\r\n]);\r\n```\r\nThis enhanced specification makes it easier to add additional attributes to take advantage of advanced client side features needed in rich web applications. It also simplifies dynamic form generation.\r\n\r\nThe associative array names are normally HTML attribute names. In some cases, these do not map directly or consistently. For example, Xoops\\Form\\Elements usually have a 'caption' attribute, but that is not part of the actual HTML input element. The 'value' attribute is usually a normal attribute, but in some cases, such as a TextArea, it is not rendered as an attribute in the tag, but as text enclosed in the tag. These inconsistencies are all handled by the base form classes.\r\n\r\nShort form attributes, such as 'required', can be specified with a value of `null` to render properly.\r\n\r\nThere is also a special set of attributes known as controls, which affect rendering or operation, but never render directly as attributes. These all begin with a ':'. One example is the ':showdelete' control in the ButtonTray element which specifies if a 'Delete' button should be included. Each class implementing a control documents it in the __construct DocBlock.\r\n\r\n`Xoops\\Form\\Element` extends `Xoops\\Html\\Attributes` which extends `\\ArrayObject`, so all element attributes can be accessed array style if needed, so there is no need for custom getters and setters, which means \"no limits!\"\r\n\r\nThere is also a new `ElementFactory` that can create any element using the enhanced specification. See *codex/form-element-factory.php* for examples.\r\n\r\nIn addition, there are a few breaking changes.\r\n\r\n- Removed size parameter from DateTime and DateSelect, so signatures are now ($caption, $name, $value) and a reasonable default size is automatically applied. This provides some system wide consistency, and makes these elements easier to work with. (These can still be altered using the enhanced specifications, if desired.)\r\n- In TabTray, the jQueryUI theme parameter was removed, as the theme is controlled by the base assets that can be established by the theme.\r\n\r\nAlso, the `Element::setExtra()` method has been deprecated, and will be removed in the future (along with getExtra().) The most common use for this is to add javascript event handlers into the form element. These are much more cleanly implemented using the enhanced specification. For example, this:\r\n\r\n`$button_2->setExtra(\"onclick='javascript:window.close();'\");`\r\n\r\nbecomes this:\r\n\r\n`$button_2->set('onclick', 'javascript:window.close();');`\r\n\r\nwhich is less convoluted, more comprehensible, and multiple event handlers can be easily specified individually, rather than in a big escape quoted blob.","created_at":"2015-11-12T04:26:46Z","updated_at":"2015-11-12T04:26:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457/commits","review_comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457/comments","review_comment_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments{/number}","comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/457/comments","statuses_url":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/bd081d13d91e617632bb77635770f942d77462f6","head":{"label":"geekwright:i453","ref":"i453","sha":"bd081d13d91e617632bb77635770f942d77462f6","user":{"login":"geekwright","id":3181636,"avatar_url":"https://avatars.githubusercontent.com/u/3181636?v=3","gravatar_id":"","url":"https://api.github.com/users/geekwright","html_url":"https://github.com/geekwright","followers_url":"https://api.github.com/users/geekwright/followers","following_url":"https://api.github.com/users/geekwright/following{/other_user}","gists_url":"https://api.github.com/users/geekwright/gists{/gist_id}","starred_url":"https://api.github.com/users/geekwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geekwright/subscriptions","organizations_url":"https://api.github.com/users/geekwright/orgs","repos_url":"https://api.github.com/users/geekwright/repos","events_url":"https://api.github.com/users/geekwright/events{/privacy}","received_events_url":"https://api.github.com/users/geekwright/received_events","type":"User","site_admin":false},"repo":{"id":12440925,"name":"XoopsCore","full_name":"geekwright/XoopsCore","owner":{"login":"geekwright","id":3181636,"avatar_url":"https://avatars.githubusercontent.com/u/3181636?v=3","gravatar_id":"","url":"https://api.github.com/users/geekwright","html_url":"https://github.com/geekwright","followers_url":"https://api.github.com/users/geekwright/followers","following_url":"https://api.github.com/users/geekwright/following{/other_user}","gists_url":"https://api.github.com/users/geekwright/gists{/gist_id}","starred_url":"https://api.github.com/users/geekwright/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geekwright/subscriptions","organizations_url":"https://api.github.com/users/geekwright/orgs","repos_url":"https://api.github.com/users/geekwright/repos","events_url":"https://api.github.com/users/geekwright/events{/privacy}","received_events_url":"https://api.github.com/users/geekwright/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/geekwright/XoopsCore","description":"XoopsCore","fork":true,"url":"https://api.github.com/repos/geekwright/XoopsCore","forks_url":"https://api.github.com/repos/geekwright/XoopsCore/forks","keys_url":"https://api.github.com/repos/geekwright/XoopsCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geekwright/XoopsCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geekwright/XoopsCore/teams","hooks_url":"https://api.github.com/repos/geekwright/XoopsCore/hooks","issue_events_url":"https://api.github.com/repos/geekwright/XoopsCore/issues/events{/number}","events_url":"https://api.github.com/repos/geekwright/XoopsCore/events","assignees_url":"https://api.github.com/repos/geekwright/XoopsCore/assignees{/user}","branches_url":"https://api.github.com/repos/geekwright/XoopsCore/branches{/branch}","tags_url":"https://api.github.com/repos/geekwright/XoopsCore/tags","blobs_url":"https://api.github.com/repos/geekwright/XoopsCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geekwright/XoopsCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geekwright/XoopsCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/geekwright/XoopsCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geekwright/XoopsCore/statuses/{sha}","languages_url":"https://api.github.com/repos/geekwright/XoopsCore/languages","stargazers_url":"https://api.github.com/repos/geekwright/XoopsCore/stargazers","contributors_url":"https://api.github.com/repos/geekwright/XoopsCore/contributors","subscribers_url":"https://api.github.com/repos/geekwright/XoopsCore/subscribers","subscription_url":"https://api.github.com/repos/geekwright/XoopsCore/subscription","commits_url":"https://api.github.com/repos/geekwright/XoopsCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/geekwright/XoopsCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/geekwright/XoopsCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/geekwright/XoopsCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/geekwright/XoopsCore/contents/{+path}","compare_url":"https://api.github.com/repos/geekwright/XoopsCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geekwright/XoopsCore/merges","archive_url":"https://api.github.com/repos/geekwright/XoopsCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geekwright/XoopsCore/downloads","issues_url":"https://api.github.com/repos/geekwright/XoopsCore/issues{/number}","pulls_url":"https://api.github.com/repos/geekwright/XoopsCore/pulls{/number}","milestones_url":"https://api.github.com/repos/geekwright/XoopsCore/milestones{/number}","notifications_url":"https://api.github.com/repos/geekwright/XoopsCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geekwright/XoopsCore/labels{/name}","releases_url":"https://api.github.com/repos/geekwright/XoopsCore/releases{/id}","created_at":"2013-08-28T18:06:06Z","updated_at":"2015-05-08T01:10:53Z","pushed_at":"2015-11-12T04:03:04Z","git_url":"git://github.com/geekwright/XoopsCore.git","ssh_url":"git@github.com:geekwright/XoopsCore.git","clone_url":"https://github.com/geekwright/XoopsCore.git","svn_url":"https://github.com/geekwright/XoopsCore","homepage":null,"size":22853,"stargazers_count":3,"watchers_count":3,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":0,"forks":2,"open_issues":0,"watchers":3,"default_branch":"master"}},"base":{"label":"XOOPS:master","ref":"master","sha":"4469b34ee4b5974a87ceb8bea6eaf46848d94f96","user":{"login":"XOOPS","id":3910043,"avatar_url":"https://avatars.githubusercontent.com/u/3910043?v=3","gravatar_id":"","url":"https://api.github.com/users/XOOPS","html_url":"https://github.com/XOOPS","followers_url":"https://api.github.com/users/XOOPS/followers","following_url":"https://api.github.com/users/XOOPS/following{/other_user}","gists_url":"https://api.github.com/users/XOOPS/gists{/gist_id}","starred_url":"https://api.github.com/users/XOOPS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XOOPS/subscriptions","organizations_url":"https://api.github.com/users/XOOPS/orgs","repos_url":"https://api.github.com/users/XOOPS/repos","events_url":"https://api.github.com/users/XOOPS/events{/privacy}","received_events_url":"https://api.github.com/users/XOOPS/received_events","type":"Organization","site_admin":false},"repo":{"id":12440699,"name":"XoopsCore","full_name":"XOOPS/XoopsCore","owner":{"login":"XOOPS","id":3910043,"avatar_url":"https://avatars.githubusercontent.com/u/3910043?v=3","gravatar_id":"","url":"https://api.github.com/users/XOOPS","html_url":"https://github.com/XOOPS","followers_url":"https://api.github.com/users/XOOPS/followers","following_url":"https://api.github.com/users/XOOPS/following{/other_user}","gists_url":"https://api.github.com/users/XOOPS/gists{/gist_id}","starred_url":"https://api.github.com/users/XOOPS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XOOPS/subscriptions","organizations_url":"https://api.github.com/users/XOOPS/orgs","repos_url":"https://api.github.com/users/XOOPS/repos","events_url":"https://api.github.com/users/XOOPS/events{/privacy}","received_events_url":"https://api.github.com/users/XOOPS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/XOOPS/XoopsCore","description":"XoopsCore","fork":false,"url":"https://api.github.com/repos/XOOPS/XoopsCore","forks_url":"https://api.github.com/repos/XOOPS/XoopsCore/forks","keys_url":"https://api.github.com/repos/XOOPS/XoopsCore/keys{/key_id}","collaborators_url":"https://api.github.com/repos/XOOPS/XoopsCore/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/XOOPS/XoopsCore/teams","hooks_url":"https://api.github.com/repos/XOOPS/XoopsCore/hooks","issue_events_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/events{/number}","events_url":"https://api.github.com/repos/XOOPS/XoopsCore/events","assignees_url":"https://api.github.com/repos/XOOPS/XoopsCore/assignees{/user}","branches_url":"https://api.github.com/repos/XOOPS/XoopsCore/branches{/branch}","tags_url":"https://api.github.com/repos/XOOPS/XoopsCore/tags","blobs_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/refs{/sha}","trees_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/trees{/sha}","statuses_url":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/{sha}","languages_url":"https://api.github.com/repos/XOOPS/XoopsCore/languages","stargazers_url":"https://api.github.com/repos/XOOPS/XoopsCore/stargazers","contributors_url":"https://api.github.com/repos/XOOPS/XoopsCore/contributors","subscribers_url":"https://api.github.com/repos/XOOPS/XoopsCore/subscribers","subscription_url":"https://api.github.com/repos/XOOPS/XoopsCore/subscription","commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/commits{/sha}","git_commits_url":"https://api.github.com/repos/XOOPS/XoopsCore/git/commits{/sha}","comments_url":"https://api.github.com/repos/XOOPS/XoopsCore/comments{/number}","issue_comment_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues/comments{/number}","contents_url":"https://api.github.com/repos/XOOPS/XoopsCore/contents/{+path}","compare_url":"https://api.github.com/repos/XOOPS/XoopsCore/compare/{base}...{head}","merges_url":"https://api.github.com/repos/XOOPS/XoopsCore/merges","archive_url":"https://api.github.com/repos/XOOPS/XoopsCore/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/XOOPS/XoopsCore/downloads","issues_url":"https://api.github.com/repos/XOOPS/XoopsCore/issues{/number}","pulls_url":"https://api.github.com/repos/XOOPS/XoopsCore/pulls{/number}","milestones_url":"https://api.github.com/repos/XOOPS/XoopsCore/milestones{/number}","notifications_url":"https://api.github.com/repos/XOOPS/XoopsCore/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/XOOPS/XoopsCore/labels{/name}","releases_url":"https://api.github.com/repos/XOOPS/XoopsCore/releases{/id}","created_at":"2013-08-28T17:54:02Z","updated_at":"2015-11-04T14:56:35Z","pushed_at":"2015-11-12T04:26:46Z","git_url":"git://github.com/XOOPS/XoopsCore.git","ssh_url":"git@github.com:XOOPS/XoopsCore.git","clone_url":"https://github.com/XOOPS/XoopsCore.git","svn_url":"https://github.com/XOOPS/XoopsCore","homepage":null,"size":23940,"stargazers_count":51,"watchers_count":51,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":55,"mirror_url":null,"open_issues_count":44,"forks":55,"open_issues":44,"watchers":51,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457"},"html":{"href":"https://github.com/XOOPS/XoopsCore/pull/457"},"issue":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/issues/457"},"comments":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/issues/457/comments"},"review_comments":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457/comments"},"review_comment":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/pulls/457/commits"},"statuses":{"href":"https://api.github.com/repos/XOOPS/XoopsCore/statuses/bd081d13d91e617632bb77635770f942d77462f6"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":9,"additions":3301,"deletions":2060,"changed_files":159}}