A
A
AltaiR2017-04-26 18:42:33
CMS
AltaiR, 2017-04-26 18:42:33

How to add select field to "Text block" module in opencart 2?

In the "Text block - HTML" module, you need to add the ability to select the title tag. The only thing that I have managed to display this field in the admin panel so far:
ed4d21549a5947b1b8c66fc9dd89ba62.png
I did this by adding the following code to the module template file in the admin panel:

<div class="form-group">
  <label class="col-sm-2 control-label" for="input-tag">Уровень заголовка</label>
  <div class="col-sm-10">
    <select name="tag" id="input-tag" class="form-control">
      <option value="1" selected="selected">H1</option>
      <option value="2">H2</option>
      <option value="3">H3</option>
      <option value="4">H4</option>
      <option value="5">H5</option>
      <option value="6">H6</option>
    </select>
  </div>
</div>

Tell me what to do next? I'm new to this topic)) As I understand it, you need to get the field value in the controller file, but I don't know how to do it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2017-11-21
@demonix26

Try this code example:

if (isset($this->request->post['module_description'])) {
      $data['module_description'] = $this->request->post['module_description'];
    } elseif (!empty($module_info)) {
      $data['module_description'] = $module_info['module_description'];
    } else {
      $data['module_description'] = '';
    }

from the same controller in the admin panel,
then in the controller in the template pull out the values ​​from the array and in the same place they seem to start up on the View.
True, we still need to think about how to save the selected select value after sending ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question