1

I'm working with magento 2. when i want to set required for Gender field in Admin. It required me to config something. This picture describes my problem

2
  • can you explain more?
    – Ajay Patel
    Apr 8, 2016 at 4:47
  • I think it is asking to specify gender options. Magento does not know the values for gender dropdown automatically. May 9, 2018 at 13:57

3 Answers 3

0

You have to add field with require as bellow.

for example in my custom module the field i have added in

Custom\News\Block\Adminhtml\Items\Edit\Tab\Main.php;

like

$fieldset->addField(
            'news_short_description',
            'editor',
            [
                'name' => 'news_short_description',
                'label' => __('Short Description'),
                'title' => __('Short Description'),
                'class' => 'validate-length maximum-length-100',
                'required' => true
            ]
        );

or as like bellow

 $fieldset->addField(
            'news_content',
            'editor',
            [
                'name' => 'news_content',
                'label' => __('Long Description'),
                'title' => __('Long Description'),
                'style' => 'height:11em',
                'required' => true,
                'disabled' => $isElementDisabled,
                'config' => $wysiwygConfig
                //'config'    => $wysiwygConfig
            ]
        );

        $dateFormat = $this->_localeDate->getDateFormat(\IntlDateFormatter::SHORT);
        $timeFormat = $this->_localeDate->getTimeFormat(\IntlDateFormatter::SHORT);
        $style = 'color: #000;background-color: #fff; font-weight: bold; font-size: 13px;';
       $fieldset->addField(
            'start_time',
            'date',
            [
                'name' => 'start_time',
                'label' => __('Starting time'),
                'title' => __('Starting time'),
                'required' => true,
                'readonly' => true,
                'style' => $style,
                'class' => 'required-entry',
                'date_format' => $dateFormat,
                'time_format' => $timeFormat,
            ]
        );

I hope this will help you.

2
  • tks u, i'll try it.
    – ATT
    Apr 10, 2016 at 14:50
  • MWC...i hope this will help you. Apr 11, 2016 at 6:55
0

I think it is asking to specify gender options. Magento does not know the values for gender dropdown automatically.

You just have to specify values for the gender dropdown.

0

Add like this :-

$fieldset->addField(
            'news_short_description',
            'editor',
            [
                'name' => 'news_short_description',
                'label' => __('Short Description'),
                'title' => __('Short Description'),
                'class' => 'validate-length maximum-length-100',
                'required' => true
            ]
        );

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.