@@ -23,12 +23,18 @@ class Main extends \Magento\Backend\Block\Widget\Form\Generic implements \Magent
2323 */
2424 protected $ _categoryOption ;
2525
26+ /**
27+ * @var \Magefan\Blog\Model\Config\Source\Author
28+ */
29+ protected $ _authoryOption ;
30+
2631 /**
2732 * @param \Magento\Backend\Block\Template\Context $context
2833 * @param \Magento\Framework\Registry $registry
2934 * @param \Magento\Framework\Data\FormFactory $formFactory
3035 * @param \Magento\Store\Model\System\Store $systemStore
3136 * @param \Magefan\Blog\Model\Config\Source\Category $categoryOption
37+ * @param \Magefan\Blog\Model\Config\Source\Author $authoryOption
3238 * @param array $data
3339 */
3440 public function __construct (
@@ -37,10 +43,12 @@ public function __construct(
3743 \Magento \Framework \Data \FormFactory $ formFactory ,
3844 \Magento \Store \Model \System \Store $ systemStore ,
3945 \Magefan \Blog \Model \Config \Source \Category $ categoryOption ,
46+ \Magefan \Blog \Model \Config \Source \Author $ authoryOption ,
4047 array $ data = []
4148 ) {
4249 $ this ->_systemStore = $ systemStore ;
4350 $ this ->_categoryOption = $ categoryOption ;
51+ $ this ->_authoryOption = $ authoryOption ;
4452 parent ::__construct ($ context , $ registry , $ formFactory , $ data );
4553 }
4654
@@ -112,6 +120,18 @@ protected function _prepareForm()
112120 $ model ->setData ('is_active ' , $ isElementDisabled ? '0 ' : '1 ' );
113121 }
114122
123+ $ field = $ fieldset ->addField (
124+ 'author_id ' ,
125+ 'select ' ,
126+ [
127+ 'name ' => 'post[author_id] ' ,
128+ 'label ' => __ ('Author ' ),
129+ 'title ' => __ ('Author ' ),
130+ 'values ' => $ this ->_authoryOption ->toOptionArray (),
131+ 'disabled ' => $ isElementDisabled ,
132+ ]
133+ );
134+
115135 /**
116136 * Check is single store mode
117137 */
@@ -138,7 +158,7 @@ protected function _prepareForm()
138158 'hidden ' ,
139159 ['name ' => 'post[store_ids][] ' , 'value ' => $ this ->_storeManager ->getStore (true )->getId ()]
140160 );
141- $ model ->setStoreIds ([ $ this ->_storeManager ->getStore (true )->getId ()] );
161+ $ model ->setStoreIds ($ this ->_storeManager ->getStore (true )->getId ());
142162 }
143163
144164 $ field = $ fieldset ->addField (
0 commit comments