Loading...
X

Make a coupon field required

0 0

This snippet will make required a coupon field.

// Make required a field that doesn't have required option in form editor
add_filter( 'gform_pre_render', 'mark_field_as_required' );
add_filter( 'gform_pre_validation', 'mark_field_as_required' );
function mark_field_as_required( $form ) {
  if ( $form['id'] == 1 ) {
    foreach ( $form['fields'] as &$field ) {
      if ( $field['id'] == 3 ) {
        $field['isRequired'] = true;
      }
    }
  }

Leave Your Observation

Your email address will not be published. Required fields are marked *

Do NOT follow this link or you will be banned from the site!