/** * Initialise form fields * * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareForm() { /* * Checking if user have permissions to save information */ $isElementDisabled = !$this->_isAllowedAction('Magento_Cms::save'); /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'page_']]); $model = $this->_coreRegistry->registry('cms_page'); $layoutFieldset = $form->addFieldset('layout_fieldset', ['legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]); $layoutFieldset->addField('page_layout', 'select', ['name' => 'page_layout', 'label' => __('Layout'), 'required' => true, 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(), 'disabled' => $isElementDisabled]); if (!$model->getId()) { $model->setRootTemplate($this->_pageLayout->getDefaultValue()); } $layoutFieldset->addField('layout_update_xml', 'textarea', ['name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]); $designFieldset = $form->addFieldset('design_fieldset', ['legend' => __('Custom Design'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]); $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT); $designFieldset->addField('custom_theme_from', 'date', ['name' => 'custom_theme_from', 'label' => __('Custom Design From'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-from']); $designFieldset->addField('custom_theme_to', 'date', ['name' => 'custom_theme_to', 'label' => __('Custom Design To'), 'date_format' => $dateFormat, 'disabled' => $isElementDisabled, 'class' => 'validate-date validate-date-range date-range-custom_theme-to']); $options = $this->_labelFactory->create()->getLabelsCollection(__('-- Please Select --')); $designFieldset->addField('custom_theme', 'select', ['name' => 'custom_theme', 'label' => __('Custom Theme'), 'values' => $options, 'disabled' => $isElementDisabled]); $designFieldset->addField('custom_page_layout', 'select', ['name' => 'custom_page_layout', 'label' => __('Custom Layout'), 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(true), 'disabled' => $isElementDisabled]); $designFieldset->addField('custom_layout_update_xml', 'textarea', ['name' => 'custom_layout_update_xml', 'label' => __('Custom Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]); $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_design_prepare_form', ['form' => $form]); $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * @test * @return void * @covers \Magento\Theme\Model\Layout\Source\Layout::toOptionArray * @covers \Magento\Theme\Model\Layout\Source\Layout::getOptions * @covers \Magento\Theme\Model\Layout\Source\Layout::getDefaultValue * @covers \Magento\Theme\Model\Layout\Source\Layout::__construct */ public function testToOptionArray() { $data = ['code' => 'testCode', 'label' => 'testLabel', 'is_default' => true]; $expectedResult = [['value' => '', 'label' => __('-- Please Select --')], ['value' => 'testCode', 'label' => 'testLabel']]; $this->config->expects($this->once())->method('getPageLayouts')->willReturn([new Object($data)]); $this->assertEquals($expectedResult, $this->_model->toOptionArray(true)); $this->assertEquals('testCode', $this->_model->getDefaultValue()); }
/** * {@inheritdoc} */ public function getAllOptions() { if (!$this->_options) { $this->_options = $this->_pageSourceLayout->toOptionArray(); array_unshift($this->_options, array('value' => '', 'label' => __('No layout updates'))); } return $this->_options; }
/** * Prepare columns for pages grid * * @return $this */ protected function _prepareColumns() { $this->addColumn('chooser_id', array('header' => __('ID'), 'index' => 'page_id', 'header_css_class' => 'col-id', 'column_css_class' => 'col-id')); $this->addColumn('chooser_title', array('header' => __('Title'), 'index' => 'title', 'header_css_class' => 'col-title', 'column_css_class' => 'col-title')); $this->addColumn('chooser_identifier', array('header' => __('URL Key'), 'index' => 'identifier', 'header_css_class' => 'col-url', 'column_css_class' => 'col-url')); $this->addColumn('chooser_root_template', array('header' => __('Layout'), 'index' => 'root_template', 'type' => 'options', 'options' => $this->_pageLayout->getOptions(), 'header_css_class' => 'col-layout', 'column_css_class' => 'col-layout')); $this->addColumn('chooser_is_active', array('header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses(), 'header_css_class' => 'col-status', 'column_css_class' => 'col-status')); return parent::_prepareColumns(); }
/** * Initialise form fields * * @return $this * @SuppressWarnings(PHPMD.ExcessiveMethodLength) */ protected function _prepareForm() { /* * Checking if user have permissions to save information */ $isElementDisabled = !$this->_isAllowedAction('Ves_Brand::brand_edit'); /** @var \Magento\Framework\Data\Form $form */ $form = $this->_formFactory->create(['data' => ['html_id_prefix' => 'brand_']]); $model = $this->_coreRegistry->registry('ves_brand'); $layoutFieldset = $form->addFieldset('layout_fieldset', ['legend' => __('Page Layout'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]); $layoutFieldset->addField('page_layout', 'select', ['name' => 'page_layout', 'label' => __('Layout'), 'required' => true, 'values' => $this->pageLayoutBuilder->getPageLayoutsConfig()->toOptionArray(), 'disabled' => $isElementDisabled]); if (!$model->getId()) { $model->setRootTemplate($this->_pageLayout->getDefaultValue()); } $layoutFieldset->addField('layout_update_xml', 'textarea', ['name' => 'layout_update_xml', 'label' => __('Layout Update XML'), 'style' => 'height:24em;', 'disabled' => $isElementDisabled]); $this->_eventManager->dispatch('adminhtml_cms_page_edit_tab_design_prepare_form', ['form' => $form]); $form->setValues($model->getData()); $this->setForm($form); return parent::_prepareForm(); }
/** * Prepare columns * * @return \Magento\Backend\Block\Widget\Grid\Extended */ protected function _prepareColumns() { $baseUrl = $this->getUrl(); $this->addColumn('title', array('header' => __('Title'), 'index' => 'title')); $this->addColumn('identifier', array('header' => __('URL Key'), 'index' => 'identifier')); $this->addColumn('root_template', array('header' => __('Layout'), 'index' => 'root_template', 'type' => 'options', 'options' => $this->_pageLayout->getOptions())); /** * Check is single store mode */ if (!$this->_storeManager->isSingleStoreMode()) { $this->addColumn('store_id', array('header' => __('Store View'), 'index' => 'store_id', 'type' => 'store', 'store_all' => true, 'store_view' => true, 'sortable' => false, 'filter_condition_callback' => array($this, '_filterStoreCondition'))); } $this->addColumn('is_active', array('header' => __('Status'), 'index' => 'is_active', 'type' => 'options', 'options' => $this->_cmsPage->getAvailableStatuses())); $this->addColumn('creation_time', array('header' => __('Created'), 'index' => 'creation_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date')); $this->addColumn('update_time', array('header' => __('Modified'), 'index' => 'update_time', 'type' => 'datetime', 'header_css_class' => 'col-date', 'column_css_class' => 'col-date')); $this->addColumn('page_actions', array('header' => __('Action'), 'sortable' => false, 'filter' => false, 'renderer' => 'Magento\\Cms\\Block\\Adminhtml\\Page\\Grid\\Renderer\\Action', 'header_css_class' => 'col-action', 'column_css_class' => 'col-action')); return parent::_prepareColumns(); }