Skip to main content
added 5 characters in body
Source Link

Solved the problem yourself with the help of code. It was necessary to create a handler instead comment_form_submit and create in him the values ​​of a variable_set of my field value, so, I create custom field.

    function comment_author_form_comment_form_alter(&$form, &$form_state, $form_id){
           if($form_id == 'comment_node_zayavka_form'){
             $query = db_select('node', 'n')
                ->fields('n', array('type', 'uid', 'title', 'nid'))
                ->condition('n.type', 'brigada_type', '=');
             $result = $query->execute();
             $brigade_list = array();
                foreach($result as $value){
                    //if($value->uid == $user->uid){
                     $brigade_list[] = $value->title;
                    //} 
                }
                $form['field_select_brigade_1'] = array(
                    '#type' => 'select',
                    '#title' => t('Select brigade'),
                    '#options' => $brigade_list,
                    '#description' => t('Please select the team that was sent to you with reference to this application.'),
                    '#required' => TRUE,
                    '#default_value' => variable_get('comment_field_brigade_selection'),
                );
        $form['#submit'][]$form['#submit'] = 'comment_author_comment_form_submit';array('comment_author_comment_form_submit');
        }
function comment_author_comment_form_submit($form, &$form_state){
        if(isset($form_state['values']['field_select_brigade_1'])){
              variable_set('comment_field_brigade_selection', $form_state['values']['field_select_brigade_1']);
            }
        }

Solved the problem yourself with the help of code. It was necessary to create a handler instead comment_form_submit and create in him the values ​​of a variable_set of my field value, so, I create custom field.

    function comment_author_form_comment_form_alter(&$form, &$form_state, $form_id){
           if($form_id == 'comment_node_zayavka_form'){
             $query = db_select('node', 'n')
                ->fields('n', array('type', 'uid', 'title', 'nid'))
                ->condition('n.type', 'brigada_type', '=');
             $result = $query->execute();
             $brigade_list = array();
                foreach($result as $value){
                    //if($value->uid == $user->uid){
                     $brigade_list[] = $value->title;
                    //} 
                }
                $form['field_select_brigade_1'] = array(
                    '#type' => 'select',
                    '#title' => t('Select brigade'),
                    '#options' => $brigade_list,
                    '#description' => t('Please select the team that was sent to you with reference to this application.'),
                    '#required' => TRUE,
                    '#default_value' => variable_get('comment_field_brigade_selection'),
                );
        $form['#submit'][] = 'comment_author_comment_form_submit';
        }
function comment_author_comment_form_submit($form, &$form_state){
        if(isset($form_state['values']['field_select_brigade_1'])){
              variable_set('comment_field_brigade_selection', $form_state['values']['field_select_brigade_1']);
            }
        }

Solved the problem yourself with the help of code. It was necessary to create a handler instead comment_form_submit and create in him the values ​​of a variable_set of my field value, so, I create custom field.

    function comment_author_form_comment_form_alter(&$form, &$form_state, $form_id){
           if($form_id == 'comment_node_zayavka_form'){
             $query = db_select('node', 'n')
                ->fields('n', array('type', 'uid', 'title', 'nid'))
                ->condition('n.type', 'brigada_type', '=');
             $result = $query->execute();
             $brigade_list = array();
                foreach($result as $value){
                    //if($value->uid == $user->uid){
                     $brigade_list[] = $value->title;
                    //} 
                }
                $form['field_select_brigade_1'] = array(
                    '#type' => 'select',
                    '#title' => t('Select brigade'),
                    '#options' => $brigade_list,
                    '#description' => t('Please select the team that was sent to you with reference to this application.'),
                    '#required' => TRUE,
                    '#default_value' => variable_get('comment_field_brigade_selection'),
                );
        $form['#submit'] = array('comment_author_comment_form_submit');
        }
function comment_author_comment_form_submit($form, &$form_state){
        if(isset($form_state['values']['field_select_brigade_1'])){
              variable_set('comment_field_brigade_selection', $form_state['values']['field_select_brigade_1']);
            }
        }
Source Link

Solved the problem yourself with the help of code. It was necessary to create a handler instead comment_form_submit and create in him the values ​​of a variable_set of my field value, so, I create custom field.

    function comment_author_form_comment_form_alter(&$form, &$form_state, $form_id){
           if($form_id == 'comment_node_zayavka_form'){
             $query = db_select('node', 'n')
                ->fields('n', array('type', 'uid', 'title', 'nid'))
                ->condition('n.type', 'brigada_type', '=');
             $result = $query->execute();
             $brigade_list = array();
                foreach($result as $value){
                    //if($value->uid == $user->uid){
                     $brigade_list[] = $value->title;
                    //} 
                }
                $form['field_select_brigade_1'] = array(
                    '#type' => 'select',
                    '#title' => t('Select brigade'),
                    '#options' => $brigade_list,
                    '#description' => t('Please select the team that was sent to you with reference to this application.'),
                    '#required' => TRUE,
                    '#default_value' => variable_get('comment_field_brigade_selection'),
                );
        $form['#submit'][] = 'comment_author_comment_form_submit';
        }
function comment_author_comment_form_submit($form, &$form_state){
        if(isset($form_state['values']['field_select_brigade_1'])){
              variable_set('comment_field_brigade_selection', $form_state['values']['field_select_brigade_1']);
            }
        }