{"action":"opened","issue":{"url":"https://api.github.com/repos/orocrm/platform/issues/587","repository_url":"https://api.github.com/repos/orocrm/platform","labels_url":"https://api.github.com/repos/orocrm/platform/issues/587/labels{/name}","comments_url":"https://api.github.com/repos/orocrm/platform/issues/587/comments","events_url":"https://api.github.com/repos/orocrm/platform/issues/587/events","html_url":"https://github.com/orocrm/platform/issues/587","id":196138230,"number":587,"title":"Extended field default value","user":{"login":"alsma","id":3245855,"avatar_url":"https://avatars.githubusercontent.com/u/3245855?v=3","gravatar_id":"","url":"https://api.github.com/users/alsma","html_url":"https://github.com/alsma","followers_url":"https://api.github.com/users/alsma/followers","following_url":"https://api.github.com/users/alsma/following{/other_user}","gists_url":"https://api.github.com/users/alsma/gists{/gist_id}","starred_url":"https://api.github.com/users/alsma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alsma/subscriptions","organizations_url":"https://api.github.com/users/alsma/orgs","repos_url":"https://api.github.com/users/alsma/repos","events_url":"https://api.github.com/users/alsma/events{/privacy}","received_events_url":"https://api.github.com/users/alsma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-16T19:38:20Z","updated_at":"2016-12-16T19:38:20Z","closed_at":null,"body":"Hi! We use extended fields to add \"soft delete\" functionality for some entities.\r\nAnd currently found an issue related to default value of fields of this kind.\r\nI've added it in a following way in migration\r\n```\r\n        $userTable->addColumn(\r\n            SoftDelete::FIELD_NAME,\r\n            'boolean',\r\n            [\r\n                'default'     => (int)SoftDelete::VALUE_NON_DELETED,\r\n                'oro_options' => [\r\n                    ExtendOptionsManager::MODE_OPTION => ConfigModel::MODE_HIDDEN,\r\n                    'extend'                          => ['is_extend' => true, 'owner' => ExtendScope::OWNER_CUSTOM],\r\n                    'datagrid'                        => ['is_visible' => DatagridScope::IS_VISIBLE_FALSE],\r\n                    'merge'                           => ['display' => false],\r\n                    'dataaudit'                       => ['auditable' => false],\r\n                    'view'                            => ['is_displayable' => false],\r\n                    'importexport'                    => ['excluded' => true],\r\n                    'form'                            => ['is_enabled' => false]\r\n                ]\r\n            ]\r\n        );\r\n    }\r\n```\r\n\r\nSo it set default value on DB level, but it's impossible to set default value on property level. Due to this fact it required to add event listener that handles prePersist, which looks like boilerplate.\r\n\r\n```\r\nclass DoctrineListener\r\n{\r\n    public function prePersist($entity)\r\n    {\r\n        if (null === $entity->getIsDeleted()) {\r\n            $email->setIsDeleted(false);\r\n        }\r\n    }\r\n}\r\n\r\n```"}}
{"actor":{"display_login":"alsma"}}