{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/20528","repository_url":"https://api.github.com/repos/symfony/symfony","labels_url":"https://api.github.com/repos/symfony/symfony/issues/20528/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/20528/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/20528/events","html_url":"https://github.com/symfony/symfony/issues/20528","id":189389131,"number":20528,"title":"Can't create a child form type of the SubmitType","user":{"login":"tzfrs","id":3509557,"avatar_url":"https://avatars.githubusercontent.com/u/3509557?v=3","gravatar_id":"","url":"https://api.github.com/users/tzfrs","html_url":"https://github.com/tzfrs","followers_url":"https://api.github.com/users/tzfrs/followers","following_url":"https://api.github.com/users/tzfrs/following{/other_user}","gists_url":"https://api.github.com/users/tzfrs/gists{/gist_id}","starred_url":"https://api.github.com/users/tzfrs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tzfrs/subscriptions","organizations_url":"https://api.github.com/users/tzfrs/orgs","repos_url":"https://api.github.com/users/tzfrs/repos","events_url":"https://api.github.com/users/tzfrs/events{/privacy}","received_events_url":"https://api.github.com/users/tzfrs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":5,"created_at":"2016-11-15T13:17:05Z","updated_at":"2016-11-15T13:36:25Z","closed_at":null,"body":"In my HTML I want to create a button which has HTML as a label (button text) because I want to use the `material-icons`. The problem is, that the `SubmitType` doesn't transform the HTML to HTML but just prints it onto the button, so I wanted to create a custom form type which inherits from the `SubmitType` and renders the HTML. So I created a new `FormType`\r\n\r\n```\r\n<?php\r\nnamespace Acme\\FrontendBundle\\Form\\Type;\r\n\r\nuse Symfony\\Component\\Form\\AbstractType;\r\nuse Symfony\\Component\\Form\\Extension\\Core\\Type\\SubmitType;\r\n\r\n/**\r\n * Class HtmlSubmitType\r\n *\r\n * This form type is used for submit buttons which need HTML for the data (e.g. label). The html rendering is defined\r\n * in the fields.html.twig file\r\n *\r\n * @category Form Type\r\n * @package  Acme\\FrontendBundle\\Form\\Type\r\n * @link     http://www.example.com\r\n * @author   Theo Tzaferis <email@example.com>\r\n */\r\nclass HtmlSubmitType extends AbstractType\r\n{\r\n    /**\r\n     * @inheritdoc\r\n     */\r\n    public function getParent()\r\n    {\r\n        return SubmitType::class;\r\n    }\r\n}\r\n```\r\n\r\nHowever, when using this form field in a `FormType` which has this as the default data_class ` 'data_class' => ResolvedVendor::class` and adding it\r\n\r\n`->add(sprintf('quote_%s', $vendor->getToken()), HtmlSubmitType::class)`\r\n\r\nI'm always getting the error \r\n\r\n> Neither the property \"quote_25v9nt1puvms\" nor one of the methods \"getQuote25v9nt1puvms()\", \"quote25v9nt1puvms()\", \"isQuote25v9nt1puvms()\", \"hasQuote25v9nt1puvms()\", \"__get()\" exist and have public access in class \"Acme\\FrontendBundle\\Model\\Cart\\ResolvedVendor\".\r\n\r\nI don't really understand it, since the documentation says \r\n\r\n>Here, the return value of the getParent function indicates that you're extending the ChoiceType field. This means that, by default, you inherit all of the logic and rendering of that field type\r\n\r\nand also it's a submit button, why does it need to be mapped? Why does this error not get thrown when using the `SubmitType` but when extending from it? I also can't set the option `mapped` to false, since it's not a valid option for the `SubmitType` which makes sense, but then why am I getting the error? "},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/260642622","html_url":"https://github.com/symfony/symfony/issues/20528#issuecomment-260642622","issue_url":"https://api.github.com/repos/symfony/symfony/issues/20528","id":260642622,"user":{"login":"stof","id":439401,"avatar_url":"https://avatars.githubusercontent.com/u/439401?v=3","gravatar_id":"","url":"https://api.github.com/users/stof","html_url":"https://github.com/stof","followers_url":"https://api.github.com/users/stof/followers","following_url":"https://api.github.com/users/stof/following{/other_user}","gists_url":"https://api.github.com/users/stof/gists{/gist_id}","starred_url":"https://api.github.com/users/stof/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stof/subscriptions","organizations_url":"https://api.github.com/users/stof/orgs","repos_url":"https://api.github.com/users/stof/repos","events_url":"https://api.github.com/users/stof/events{/privacy}","received_events_url":"https://api.github.com/users/stof/received_events","type":"User","site_admin":false},"created_at":"2016-11-15T13:36:25Z","updated_at":"2016-11-15T13:36:25Z","body":"I don't think this is documented. I'm not even sure the doc team is aware of this specific case (I was not until a few minutes ago) when I looked for it).\r\nPlease open an issue on the doc repo about it. We should have a cookbook article about creating custom form button types (even though it is not common). \r\n\r\nFYI, there are 2 available interfaces: ``Symfony\\Component\\Form\\SubmitButtonTypeInterface`` for form types creating a submit button and ``Symfony\\Component\\Form\\ButtonTypeInterface`` for types creating another kind of buttons.\r\nAnd the type hierarchy does not apply when handling these markers currently. Child types must implement the interface too (which is what needs to be documented)"}}
{"actor":{"display_login":"stof"}}