37 var
$icon =
'dashicons-list-view';
41 $this->label = esc_html__(
'List',
'gk-gravityview' );
43 parent::__construct();
45 add_filter(
'gravityview/template/field_label', array( $this,
'_filter_field_label' ), 10, 4 );
47 add_filter(
'gravityview/common/get_form_fields', array( $this,
'add_form_fields' ), 10, 3 );
49 add_filter(
'gravityview/search/searchable_fields', array( $this,
'remove_columns_from_searchable_fields' ), 10 );
64 foreach ( $fields as $key =>
$field ) {
65 if ( isset(
$field[
'parent'] ) &&
$field[
'parent'] instanceof \GF_Field_List ) {
66 unset( $fields[ $key ] );
86 $list_fields = GFAPI::get_fields_by_type(
$form,
'list' );
89 foreach ( $list_fields as $list_field ) {
91 if( empty( $list_field->enableColumns ) ) {
95 $list_columns = array();
97 foreach ( (array)$list_field->choices as $key => $input ) {
99 $input_id = sprintf(
'%d.%d', $list_field->id, $key );
102 'label' => \
GV\Utils::get( $input,
'text' ),
104 'parent' => $list_field,
105 'type' => \
GV\Utils::get( $list_field,
'type' ),
106 'adminLabel' => \
GV\Utils::get( $list_field,
'adminLabel' ),
107 'adminOnly' => \
GV\Utils::get( $list_field,
'adminOnly' ),
112 if( ! empty( $list_columns ) ) {
114 $index = array_search( $list_field->id, array_keys( $fields ) ) + 1;
120 $fields = array_slice( $fields, 0, $index,
true) + $list_columns + array_slice( $fields, $index, null,
true);
123 unset( $list_columns, $index,
$input_id );
147 if( ! is_array( $list_rows ) ) {
152 $column_values = array();
155 foreach ( $list_rows as $list_row ) {
157 foreach ( (array) $list_row as $column_key => $column_value ) {
161 $column_values[] = $column_value;
169 return $column_values;
173 return $field->get_value_entry_detail( serialize( $column_values ),
'',
false,
$format );
191 $field_object = RGFormsModel::get_field(
$form,
$field[
'id'] );
194 if( ! $field_object ||
'list' !== $field_object->type ) {
199 if( ! empty(
$field[
'custom_label'] ) ) {
227 if( ! isset( $field->choices ) || ! $field->enableColumns ) {
228 return $backup_label;
232 $columns = wp_list_pluck( $field->choices,
'text' );
Modify field settings by extending this class.
_filter_field_label( $label, $field, $form, $entry)
When showing a single column values, display the label of the column instead of the field...
if(gv_empty( $field['value'], false, false)) $format
add_form_fields( $fields=array(), $form=array(), $include_parent_field=true)
If a form has list fields, add the columns to the field picker.
remove_columns_from_searchable_fields( $fields)
Removes columns from searchable field dropdown.
if(gravityview() ->plugin->is_GF_25()) $form
gravityview_get_input_id_from_id( $field_id='')
Very commonly needed: get the # of the input based on a full field ID.
new GravityView_Field_List
Add custom options for list fields.
static get_column_label(GF_Field_List $field, $column_id, $backup_label='')
Get the column label for the list.
gravityview()
The main GravityView wrapper function.
static column_value(GF_Field_List $field, $field_value, $column_id=0, $format='html')
Get the value of a Multiple Column List field for a specific column.