";
/**
* Override the default choice markup used when rendering radio button, checkbox and drop down type fields.
*
* @since 1.9.6
*
* @param string $choice_markup The string containing the choice markup to be filtered.
* @param array $choice An associative array containing the choice properties.
* @param object $field The field currently being processed.
* @param string $value The value to be selected if the field is being populated.
*/
$select_all = gf_apply_filters( array( 'gform_field_choice_markup_pre_render', $this->formId, $this->id ), $choice_markup, array(), $this, $value );
return $select_all;
}
/**
* Get the choice alignment for the given field.
*
* @since 2.9.0
*
* @param object $field The field object.
* @return string
*/
public static function get_field_choice_alignment( $field ) {
return rgempty( 'choiceAlignment', $field ) ? self::get_default_choice_alignment( $field ) : $field->choiceAlignment;
}
/**
* Get the default choice alignment for the multi_choice field.
*
* @since 2.9.0
*
* @param object $field The field object.
* @return string
*/
public static function get_default_choice_alignment( $field) {
/*
* Filter the default choice alignment. Default is vertical. Options are 'vertical' and 'horizontal'.
*
* @since 2.9.0
*
* @param string $default_choice_alignment The default choice alignment.
* @param object $field The field.
*
* @return string
*/
return gf_apply_filters( array( 'gform_default_choice_alignment', $field->formId ), 'vertical', $field );
}
public function get_form_editor_inline_script_on_page_render() {
$alignment = self::get_default_choice_alignment( $this );
return "gform.addAction( 'gform_post_load_field_settings', function( [ field, form ] ) { if( '" . $alignment . "' == 'horizontal' ) { jQuery('#choice_alignment_horizontal').prop('checked', true); } else { jQuery('#choice_alignment_vertical').prop('checked', true); } } );";
}
}
GF_Fields::register( new GF_Field_Multiple_Choice() );