How do I change form labels and options
Filter twp_form_options
helps with customizing form options.
In your theme’s functions.php
file, add similar code as follows to make a particular field required or to change a form field label.
function my_twp_form_options( $array ) {
// uncomment below to view incoming options
// print_r( $array );
$array['meta_email']['validate'] = 'sanitize_email,required';
$array['post_content']['title'] = 'Why do you love us?';
$array['post_content']['placeholder'] = 'I love you because'; // placeholder example
$array['post_content']['maxlength'] = 500; // maxlength example to limit testimonial content to 500 characters
$array['meta_email']['std'] = 'support@example.com'; // std is the default field value
$array['post_content']['validate'] = 'wp_kses_post,stripslashes'; // remove the testimonial content field required option
$array['featured_image']['validate'] = 'required';
$array['meta_location']['validate'] = 'sanitize_text_field,stripslashes,required';
$array['post_excerpt']['placeholder'] = 'Fantastic!';
return $array;
}
add_filter( 'twp_form_options', 'my_twp_form_options' );
Form fields options are handled via `Testimonials_Widget_Settings::display_setting()` and `Display Settings::display_setting()`. These give you the ability to configure `text`, `textarea`, `select`, `checkbox`, and other field types. It's suggested to look at the `settings` functions of Testimonials to see configuration samples.
Reorder Fields
To reorder fields, you'll need to rebuild the incoming field `$array` above in the order you want using `array_pop`, `array_shift`, or creating a new `array` to return. Or see The Template Way below.
The Template Way
See How to change testimonials layout to completely customize the form template `testimonials-widget-premium/templates/testimonial-form.php` however you want.
Want to Add Form Fields?
See Gist Add a field to Testimonials Premium.