예제 #1
0
 /**
  * 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();
 }
예제 #2
0
파일: General.php 프로젝트: aiesh/magento2
 /**
  * Initialise form fields
  *
  * @return void
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $fieldset = $form->addFieldset('general', array('legend' => __('General Settings')));
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_id', 'select', array('label' => __('Store'), 'title' => __('Store'), 'values' => $this->_systemStore->getStoreValuesForForm(), 'name' => 'store_id', 'required' => true));
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     } else {
         $fieldset->addField('store_id', 'hidden', array('name' => 'store_id', 'value' => $this->_storeManager->getStore(true)->getId()));
     }
     /** @var $label \Magento\Framework\View\Design\Theme\Label */
     $label = $this->_labelFactory->create();
     $options = $label->getLabelsCollection(__('-- Please Select --'));
     $fieldset->addField('design', 'select', array('label' => __('Custom Design'), 'title' => __('Custom Design'), 'values' => $options, 'name' => 'design', 'required' => true));
     $dateFormat = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_SHORT);
     $fieldset->addField('date_from', 'date', array('label' => __('Date From'), 'title' => __('Date From'), 'name' => 'date_from', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
     $fieldset->addField('date_to', 'date', array('label' => __('Date To'), 'title' => __('Date To'), 'name' => 'date_to', 'image' => $this->getViewFileUrl('images/grid-cal.gif'), 'date_format' => $dateFormat));
     $formData = $this->_backendSession->getDesignData(true);
     if (!$formData) {
         $formData = $this->_coreRegistry->registry('design')->getData();
     } else {
         $formData = $formData['design'];
     }
     $form->addValues($formData);
     $form->setFieldNameSuffix('design');
     $this->setForm($form);
 }
예제 #3
0
 /**
  * Retrieve options setted in column.
  * Or load if options was not set.
  *
  * @return array
  */
 public function getOptions()
 {
     $options = $this->getColumn()->getOptions();
     if (empty($options) || !is_array($options)) {
         /** @var $label \Magento\Framework\View\Design\Theme\Label */
         $label = $this->_labelFactory->create();
         $options = $label->getLabelsCollection();
     }
     return $options;
 }
 /**
  * Render array cell for prototypeJS template
  *
  * @param string $columnName
  * @return string
  */
 public function renderCellTemplate($columnName)
 {
     if ($columnName == 'value' && isset($this->_columns[$columnName])) {
         /** @var $label \Magento\Framework\View\Design\Theme\Label */
         $label = $this->_labelFactory->create();
         $options = $label->getLabelsCollection(__('-- No Theme --'));
         $element = $this->_elementFactory->create('select');
         $element->setForm($this->getForm())->setName($this->_getCellInputElementName($columnName))->setHtmlId($this->_getCellInputElementId('<%- _id %>', $columnName))->setValues($options);
         return str_replace("\n", '', $element->getElementHtml());
     }
     return parent::renderCellTemplate($columnName);
 }
예제 #5
0
파일: Main.php 프로젝트: shazal/magento2
 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function _prepareForm()
 {
     $widgetInstance = $this->getWidgetInstance();
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Storefront Properties')]);
     if ($widgetInstance->getId()) {
         $fieldset->addField('instance_id', 'hidden', ['name' => 'instance_id']);
     }
     $this->_addElementTypes($fieldset);
     $fieldset->addField('instance_code', 'select', ['name' => 'instance_code', 'label' => __('Type'), 'title' => __('Type'), 'class' => '', 'values' => $this->getTypesOptionsArray(), 'disabled' => true]);
     /** @var $label \Magento\Framework\View\Design\Theme\Label */
     $label = $this->_themeLabelFactory->create();
     $options = $label->getLabelsCollection(__('-- Please Select --'));
     $fieldset->addField('theme_id', 'select', ['name' => 'theme_id', 'label' => __('Design Package/Theme'), 'title' => __('Design Package/Theme'), 'required' => false, 'values' => $options, 'disabled' => true]);
     $fieldset->addField('title', 'text', ['name' => 'title', 'label' => __('Widget Instance Title'), 'title' => __('Widget Instance Title'), 'class' => '', 'required' => true]);
     if (!$this->_storeManager->isSingleStoreMode()) {
         $field = $fieldset->addField('store_ids', 'multiselect', ['name' => 'store_ids[]', 'label' => __('Assign to Store Views'), 'title' => __('Assign to Store Views'), 'required' => true, 'values' => $this->_store->getStoreValuesForForm(false, true)]);
         $renderer = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Store\\Switcher\\Form\\Renderer\\Fieldset\\Element');
         $field->setRenderer($renderer);
     }
     $fieldset->addField('sort_order', 'text', ['name' => 'sort_order', 'label' => __('Sort Order'), 'title' => __('Sort Order'), 'class' => '', 'required' => false, 'note' => __('Sort Order of widget instances in the same container')]);
     /* @var $layoutBlock \Magento\Widget\Block\Adminhtml\Widget\Instance\Edit\Tab\Main\Layout */
     $layoutBlock = $this->getLayout()->createBlock('Magento\\Widget\\Block\\Adminhtml\\Widget\\Instance\\Edit\\Tab\\Main\\Layout')->setWidgetInstance($widgetInstance);
     $fieldset = $form->addFieldset('layout_updates_fieldset', ['legend' => __('Layout Updates')]);
     $fieldset->addField('layout_updates', 'note', []);
     $form->getElement('layout_updates_fieldset')->setRenderer($layoutBlock);
     $this->setForm($form);
     return parent::_prepareForm();
 }
예제 #6
0
 /**
  * Prepare form before rendering HTML
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create(['data' => ['id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post']]);
     $fieldset = $form->addFieldset('base_fieldset', ['legend' => __('Settings')]);
     $this->_addElementTypes($fieldset);
     $fieldset->addField('code', 'select', ['name' => 'code', 'label' => __('Type'), 'title' => __('Type'), 'required' => true, 'values' => $this->getTypesOptionsArray()]);
     /** @var $label \Magento\Framework\View\Design\Theme\Label */
     $label = $this->_themeLabelFactory->create();
     $options = $label->getLabelsCollection(__('-- Please Select --'));
     $fieldset->addField('theme_id', 'select', ['name' => 'theme_id', 'label' => __('Design Theme'), 'title' => __('Design Theme'), 'required' => true, 'values' => $options]);
     $continueButton = $this->getLayout()->createBlock('Magento\\Backend\\Block\\Widget\\Button')->setData(['label' => __('Continue'), 'onclick' => "setSettings('" . $this->getContinueUrl() . "', 'code', 'theme_id')", 'class' => 'save']);
     $fieldset->addField('continue_button', 'note', ['text' => $continueButton->toHtml()]);
     $this->setForm($form);
     return parent::_prepareForm();
 }