A
A
Alexander 1122018-12-08 20:49:02
Drupal
Alexander 112, 2018-12-08 20:49:02

How to pass the value of the text_format field of the user form with PHP code in drupal 7 for further recording in the database?

It is necessary in the settings of your own module to implement saving the value of the text_format field with the php code.
module mymodule. The file mymodule.module generates module settings with the form:

function mymodule_form($form, &$form_state, $arr = null) {
...
      $form['tmpl_code'] = array(
            '#type' => 'text_format',                                            
            '#title' => t('PHP code'),
            '#format' => 'php_code',
      );
...
}

function mymodule_form_submit($form, &$form_state)
{
  $arr = array(
    ...
    'php_code' 		=> $form_state['values']['php_code'],
    ...
  );
  ...
  drupal_write_record('mymodule', $arr);  //Здесь ошибка
  ...	
  }
  ...
}

The error occurs when saving to the database. What is the correct way to save php code to the module table of this value using Drupal methods? How to wrap the contents of a tmpl_code textbox when saving it with drupal_write_record?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question