I Want To fetch all customer name in multi select in my form using customer collection
Following is my form file
<?php
namespace Magneto\AppNotification\Block\Adminhtml\Form\Edit\Tab;
use Magento\Backend\Block\Widget\Form\Generic;
use Magento\Backend\Block\Widget\Tab\TabInterface;
use Magento\Backend\Block\Template\Context;
use Magento\Framework\Registry;
use Magento\Framework\Data\FormFactory;
use Magento\Cms\Model\Wysiwyg\Config;
class Info extends Generic implements TabInterface
{
/**
* @param Context $context
* @param Registry $registry
* @param FormFactory $formFactory
* @param Config $wysiwygConfig
* @param Status $newsStatus
* @param array $data
*/
public function __construct(
Context $context,
Registry $registry,
FormFactory $formFactory,
array $data = []
) {
parent::__construct($context, $registry, $formFactory, $data);
}
/**
* Prepare form fields
*
* @return \Magento\Backend\Block\Widget\Form
*/
protected function _prepareForm()
{
$model = $this->_coreRegistry->registry('appnotification_appnotification');
/** @var \Magento\Framework\Data\Form $form */
$form = $this->_formFactory->create();
$form->setHtmlIdPrefix('notification_');
$form->setFieldNameSuffix('notification');
$fieldset = $form->addFieldset(
'base_fieldset',
['legend' => __('AppNotification')]
);
if ($model->getId()) {
$fieldset->addField(
'id',
'hidden',
['name' => 'id']
);
}
$fieldset->addField(
'title',
'text',
[
'name' => 'title',
'label' => __('Title'),
'required' => true
]
);
$fieldset->addField(
'subtitle',
'text',
[
'name' => 'subtitle',
'label' => __('Sub Title'),
'required' => true
]
);
$fieldset->addField(
'image',
'image',
[
'label' => __('Upload Image'),
'name' => 'image',
'required'=>true
]
);
$data = $model->getData();
$form->setValues($data);
$this->setForm($form);
return parent::_prepareForm();
}
/**
* Prepare label for tab
*
* @return string
*/
public function getTabLabel()
{
return __('AppNotification Info');
}
/**
* Prepare title for tab
*
* @return string
*/
public function getTabTitle()
{
return __('AppNotification Info');
}
/**
* {@inheritdoc}
*/
public function canShowTab()
{
return true;
}
/**
* {@inheritdoc}
*/
public function isHidden()
{
return false;
}
}