form( $form_id )->get_field( $id );
$settings = $field->get_settings();
$settings[ 'options' ] = apply_filters( 'ninja_forms_render_options', $settings[ 'options' ], $settings );
$settings[ 'options' ] = apply_filters( 'ninja_forms_render_options_' . $field->get_type(), $settings[ 'options' ], $settings );
$options = '';
if ( is_array( $settings[ 'options' ] ) ) {
foreach( $settings[ 'options' ] as $option ){
$selected = ( $value == $option[ 'value' ] ) ? "selected" : '';
$options .= "";
}
}
return "";
}
/*
* Appropriate output for a column cell in submissions list.
*/
public function custom_columns( $value, $field )
{
if( $this->_name != $field->get_setting( 'type' ) ) return $value;
//Consider & to be the same as the & values in database in a selectbox saved value:
if( ! is_array( $value ) ) $value = array( htmlspecialchars_decode($value) );
$output = '';
$options = $field->get_setting( 'options' );
if( ! empty( $options ) ) {
foreach ($options as $option) {
if ( ! in_array( $option[ 'value' ], $value ) ) continue;
$output .= esc_html( $option[ 'label' ] ) . "
";
}
}
return $output;
}
public function query_string_default( $options, $settings )
{
if( ! isset( $settings[ 'key' ] ) ) return $options;
$field_key = $settings[ 'key' ];
if( ! isset( $_GET[ $field_key ] ) ) return $options;
foreach( $options as $key => $option ){
if( ! isset( $option[ 'value' ] ) ) continue;
if( $option[ 'value' ] != $_GET[ $field_key ] ) continue;
$options[ $key ][ 'selected' ] = 1;
}
return $options;
}
}