0

I am developing custom module. Other fields are saving data in database but i have issue with Dropdown field. It's not saving value in database. My code as following:

$elements['target'] = $fieldset->addField(
        'target',
        'select',
        [
            'name' => 'target',
            'label' => __('Link Target'),
            'title' => __('Select target of slide item\'s link'),
            'required' => true,
            'options' => $model->getLinkTargetOptions()
        ]
    );

In the model file

public function getLinkTargetOptions()
{
    return [
        '_self' => __('Self'),
        '_blank' => __('Blank'),  
    ];
}   

Above code adding Dropdown in the admin form. I don't know how to store it's value.

0
  1. You need to Create model for your custom table collection
  2. Retrieve Custom table data into your getLinkTargetOptions() function and add that option data into your option array.
  3. If you want to store selected option value into your custom table then after save event you can store selected data into your table.

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.