custom field at answer form / step by step guide

8.42K viewsGeneralcustom custom field
0

hi, i’m sorry cause i repeat the same question but i want to know how can i add custom field at answer form (a really step by step guide if is possible).
I read the orders at this link https://anspress.io/resources/faq/anspress-form-and-validation-api/ but i can’t understand where (in which file) to put a code, how to put a code etc.
If you know and you have time please submit a guide about custom fields………thanks for the support.

Unselected an answer
0

Here is an example hook for you 😉

/**
 * A sample hook to add custom fields to answer form.
 *
 * @param array $form Form arguments.
 * @return array
 * @author Rahul ARyan <[email protected]>
 */
function my_custom_answer_fields( $form ) {
 $form['fields']['text_field_1'] = array(
  'name' => __( 'Text field 1' ),
  'desc' => __( 'Description for this field' ),
  // 'type' => 'input', // Default is input text field.
 );
  $form['fields']['textarea_1'] = array(
  'name' => __( 'Textarea 1' ),
  'desc' => __( 'Description for this field' ),
  'type' => 'textarea',
 );
   $form['fields']['select_1'] = array(
  'name'    => __( 'Select 1' ),
  'desc'    => __( 'Select field' ),
  'type'    => 'select',
  'options' => array(
   'val1' => 'Value 1',
   'val2' => 'Value 2',
   'val3' => 'Value 3',
   'val4' => 'Value 4',
  ),
 );
  return $form;
}
add_filter( 'ap_answer_form_fields', 'my_custom_answer_fields' );

Unselected an answer
You are viewing 1 out of 4 answers, click here to view all answers.