1

I am having a form, and a select type field which is rendering good and have correct options but when I am editing an existing record it won't point to the corresponding value.

CODE

$fieldset->addField(
                'segment',
                'select',
                [
                    'name' => 'segment',
                    'label' => __('Segment'),
                    'id' => 'segment',
                    'title' => __('Segment'),
                    'required' => true,
                    'value' => $model->getSegmentCode(),
                    'values' => $options
                ],
                'sender_email'
            );

What I always got is select with options.

I can't screenshot when its open :D.

enter image description here

1 Answer 1

1

I believe the block loads values based on the data keys. Based on your sample code I am guessing the value you want is in the column segment_code because $model->getSegmentCode() is probably the same as $model->getData('segment_code') if you are extending AbstractModel or DataObject.

If that's the case then try changing the field name to segment_code and it should fill the value accordingly.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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