0

I want to Use All CMS pages and All categories Multiselect in My Block Form.
I have already created form.php in

Vendor\Module\Block\AdminHtml\Grid\Edit

 protected function _prepareForm()
{
    $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
    $model = $this->_coreRegistry->registry('row_data');
    $form = $this->_formFactory->create(
        ['data' => [
                        'id' => 'edit_form', 
                        'enctype' => 'multipart/form-data', 
                        'action' => $this->getData('action'), 
                        'method' => 'post'
                    ]
        ]
    );

    $form->setHtmlIdPrefix('wkgrid_');
    if ($model->getEntityId()) {
        $fieldset = $form->addFieldset(
            'base_fieldset',
            ['legend' => __('Edit Row Data'), 'class' => 'fieldset-wide']
        );
        $fieldset->addField('entity_id', 'hidden', ['name' => 'entity_id']);
    } else {
        $fieldset = $form->addFieldset(
            'base_fieldset',
            ['legend' => __('Add Row Data'), 'class' => 'fieldset-wide']
        );
    }

    $fieldset->addField(
        'title',
        'text',
        [
            'name' => 'title',
            'label' => __('Title'),
            'id' => 'title',
            'title' => __('Title'),
            'class' => 'required-entry',
            'required' => true,
        ]
    );

    $wysiwygConfig = $this->_wysiwygConfig->getConfig(['tab_id' => $this->getTabId()]);

    $fieldset->addField(
        'background',
        'image',
        [
            'name' => 'background',
            'label' => __('Background Image'),
            'title' => __('Background Image'),
            'required'  => true
        ]
    );
            $fieldset->addField(
        'status',
        'select',
        [
            'name' => 'status',
            'label' => __('Status'),
            'id' => 'status',
            'title' => __('Status'),
            'values' => $this->_options->getOptionArray(),
            'class' => 'status',
            'required' => true,
        ]
    );
    $form->setValues($model->getData());
    $form->setUseContainer(true);
    $this->setForm($form);

    return parent::_prepareForm();
}

I want to Add CMS pages Multiselect and Catagory Multiselect Atter bacground

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.