17 class Form extends \Magento\Backend\Block\Widget\Form\Generic
51 $this->_fieldVisibility[
$fieldId] = (bool)$visibility;
64 if (!array_key_exists(
$fieldId, $this->_fieldVisibility)) {
65 return $defaultVisibility;
67 return $this->_fieldVisibility[
$fieldId];
86 if (!array_key_exists(
$fieldId, $this->_fieldOptions)) {
90 $this->_fieldOptions[
$fieldId][$k] = $v;
104 $this->_reportTypeOptions[$key] =
__(
$value);
115 $actionUrl = $this->
getUrl(
'*/*/sales');
118 $form = $this->_formFactory->create(
121 'id' =>
'filter_form',
122 'action' => $actionUrl,
128 $htmlIdPrefix =
'sales_report_';
129 $form->setHtmlIdPrefix($htmlIdPrefix);
130 $fieldset = $form->addFieldset(
'base_fieldset', [
'legend' =>
__(
'Filter')]);
132 $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
134 $fieldset->addField(
'store_ids',
'hidden', [
'name' =>
'store_ids']);
140 'name' =>
'report_type',
141 'options' => $this->_reportTypeOptions,
142 'label' =>
__(
'Date Used')
150 'name' =>
'period_type',
151 'options' => [
'day' =>
__(
'Day'),
'month' =>
__(
'Month'),
'year' =>
__(
'Year')],
152 'label' =>
__(
'Period'),
153 'title' =>
__(
'Period')
162 'date_format' => $dateFormat,
163 'label' =>
__(
'From'),
164 'title' =>
__(
'From'),
166 'css_class' =>
'admin__field-small',
167 'class' =>
'admin__control-text' 176 'date_format' => $dateFormat,
180 'css_class' =>
'admin__field-small',
181 'class' =>
'admin__control-text' 189 'name' =>
'show_empty_rows',
190 'options' => [
'1' =>
__(
'Yes'),
'0' =>
__(
'No')],
191 'label' =>
__(
'Empty Rows'),
192 'title' =>
__(
'Empty Rows')
196 $form->setUseContainer(
true);
199 return parent::_prepareForm();
210 $data = $this->getFilterData()->getData();
217 return parent::_initFormValues();
227 $result = parent::_beforeToHtml();
230 $fieldset = $this->
getForm()->getElement(
'base_fieldset');
232 if (is_object($fieldset) && $fieldset instanceof \
Magento\Framework\Data\
Form\Element\Fieldset) {
234 foreach ($fieldset->getElements() as $field) {
236 $fieldset->removeField($field->getId());
240 foreach ($this->_fieldOptions as
$fieldId => $fieldOptions) {
241 $field = $fieldset->getElements()->searchById(
$fieldId);
244 foreach ($fieldOptions as $k => $v) {
245 $field->setDataUsingMethod($k, $v);
getUrl($route='', $params=[])