How to add date field in admin in Magento 2
In Magento 2 to add date field in admin from a core model, pass all required to parent::__construct() arguments, which should be called from __construct(). Please note that both your construct class and parent construct must accept the same list of arguments. Add new dependencies in the following way:
In case of parent construct:
1 |
public function __construct( \Parent\Required\Dependency $parentRequiredDependency, \Parent\Optional\Dependency $parentOptionalDependency = null ) { /** Parent code goes here */ } |
In case of child construct:
1 |
public function __construct( \Parent\Required\Dependency $parentRequiredDependency, \New\Required\Dependency $newRequiredDependency, \Parent\Optional\Dependency $parentOptionalDependency = null, \New\Optional\Dependency $newOptionalDependency = null ) { parent::__construct($parentRequiredDependency, $parentOptionalDependency); /** Custom code goes here */ } |
Source (