0

我正在使用以下代码更改通过管理面板制作的表单,以将文本从第一个 textarea 复制到第二个。这是通过单击“复制”按钮完成的。前端按预期运行良好。

但是,当我使用默认提交按钮提交表单时,textareas 中的值不会添加到数据库中。因此,如果我从管理面板转到网络表单结果,我看不到任何值。

我需要为此添加任何内容到自定义提交处理程序吗?

谢谢

function fence_quote_form_alter(&$form, &$form_state, $form_id) {
  if ($form_id == 'webform_client_form_1'){
    $form['input'] = array(
        '#type' => 'textarea',
        '#title' => t('Input text'),
        '#prefix' => '<div id="in-text">',
        '#attributes' => array(
            'placeholder' => t('Enter some text here... '),
        ),
        '#suffix' => '</div>',
    );

    $form['buttons']['fence_quote']  = array(
        '#type' => 'button',
        '#value' => t('Copy'),
        '#ajax' => array(
        'callback' => 'fence_quote_form_callback',
        'wrapper' => 'out-text',
        ),
    );


    $form['output'] = array(
        '#type' => 'textarea',
        '#title' => t('Output text:'),
        '#prefix' => '<div id="out-text">',
        '#value' => '',
        '#attributes' => array(
            'placeholder' => t('Your text will appear here...'),
        ),
        '#suffix' => '</div>',
    );

    $form['#validate'][] = 'mymodule_someform_custom_validation';

    $form['#submit'][] = 'my_custom_submit_function_submit';


  }

}


function fence_quote_form_callback($form, &$form_state) {
  $form['output']['#value'] = $form_state['values']['input'];
  return $form['output']; 
}


function my_custom_submit_function_submit($form, &$form_state) {

}
4

0 回答 0