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.


                    'name' => 'segment',
                    'label' => __('Segment'),
                    'id' => 'segment',
                    'title' => __('Segment'),
                    'required' => true,
                    'value' => $model->getSegmentCode(),
                    'values' => $options

What I always got is select with options.

I can't screenshot when its open :D.

enter image description here


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.

|improve this answer|||||

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.