';
return $list;
}
/**
* Builds the input that will be inside the List field.
*
* @since Unknown
* @access public
*
* @uses GF_Field::get_tabindex()
* @uses GF_Field::is_form_editor()
* @uses GF_Field_List::$choices
*
* @param bool $has_columns If the input has columns.
* @param array $column The column details.
* @param string $value The existing value of the input.
* @param int $form_id The form ID.
*
* @return string The input HTML markup.
*/
public function get_list_input( $has_columns, $column, $value, $form_id ) {
$tabindex = $this->get_tabindex();
$disabled = $this->is_form_editor() ? 'disabled' : '';
$column_index = 1;
if ( $has_columns && is_array( $this->choices ) ) {
foreach ( $this->choices as $choice ) {
if ( $choice['text'] == $column['text'] ) {
break;
}
$column_index ++;
}
}
$input_info = array( 'type' => 'text' );
/**
* Filters the column input.
*
* @since Unknown
*
* @param array $input_info Information about the input. Contains the input type.
* @param object GF_Field_List Field object for this field type.
* @param string $column['text'] The column text value.
* @param int $form_id The form ID.
*/
$input_info = gf_apply_filters( array(
'gform_column_input',
$form_id,
$this->id,
$column_index
), $input_info, $this, rgar( $column, 'text' ), $value, $form_id );
switch ( $input_info['type'] ) {
case 'select' :
$input = "';
break;
default :
$input = "";
break;
}
/**
* Filters the column input HTML markup.
*
* @since Unknown
*
* @param string $input The input markup.
* @param array $input_info The information that was used to build the input.
* @param object GF_Field_List An instance of the List field object.
* @param string $column['text'] The column text value.
* @param int $form_id The form ID.
*/
return gf_apply_filters( array(
'gform_column_input_content',
$form_id,
$this->id,
$column_index
), $input, $input_info, $this, rgar( $column, 'text' ), $value, $form_id );
}
/**
* Gets the CSS class to be used in the field label.
*
* @since Unknown
* @access public
*
* @used-by GF_Field::get_field_content()
*
* @return string String containing the CSS class names.
*/
public function get_field_label_class(){
$has_columns = is_array( $this->choices );
return $has_columns ? 'gfield_label gfield_label_before_complex' : 'gfield_label';
}
/**
* Gets the value of te field from the form submission.
*
* @since Unknown
* @access public
*
* @used-by GFFormsModel::get_field_value()
* @uses GF_Field::get_input_value_submission()
* @uses GF_Field_List::create_list_array()
*
* @param array $field_values The properties to search for.
* @param bool $get_from_post_global_var If the global GET variable should be used to obtain the value. Defaults to true.
*
* @return array The submission value.
*/
public function get_value_submission( $field_values, $get_from_post_global_var = true ) {
$value = $this->get_input_value_submission( 'input_' . $this->id, $this->inputName, $field_values, $get_from_post_global_var );
// Allow the value to be an array of row arrays in addition to the array of rows.
if ( is_array( rgar( $value, 0 ) ) ){
// Already in correct format, return value unchanged.
return $value;
}
// Not already in the correct format.
$value = $this->create_list_array( $value );
return $value;
}
/**
* Check if the submission value is empty.
*
* @since Unknown
* @access public
*
* @used-by GFFormDisplay::is_empty()
* @uses GF_Field_List::$id
*
* @param int $form_id The form ID to check.
*
* @return bool True if empty. False otherwise.
*/
public function is_value_submission_empty( $form_id ) {
$value = rgpost( 'input_' . $this->id );
if ( is_array( $value ) ) {
// Empty if all inputs are empty (for inputs with the same name).
foreach ( $value as $input ) {
if ( strlen( trim( $input ) ) > 0 ) {
return false;
}
}
}
return true;
}
/**
* Gets the field value HTML markup to be used on the entry detail page.
*
* @since Unknown
* @access public
*
* @used-by GFCommon::get_lead_field_display()
*
* @param array $value The submitted entry value.
* @param string $currency Not used.
* @param bool $use_text Not used.
* @param string $format The format to be used when building the items.
* Accepted values are text, url, or html. Defaults to html.
* @param string $media Defines how the content will be output.
* Accepted values are screen or email. Defaults to screen.
*
* @return string The HTML markup to be displayed.
*/
public function get_value_entry_detail( $value, $currency = '', $use_text = false, $format = 'html', $media = 'screen' ) {
if ( empty( $value ) ) {
return '';
}
$value = maybe_unserialize( $value );
if( ! is_array( $value ) || ! isset( $value[0] ) ) {
return '';
}
$has_columns = is_array( $value[0] );
if ( ! $has_columns ) {
$items = '';
foreach ( $value as $key => $item ) {
if ( ! empty( $item ) ) {
$item = wp_kses_post( $item );
switch ( $format ) {
case 'text' :
$items .= $item . ', ';
break;
case 'url' :
$items .= $item . ',';
break;
default :
if ( $media == 'email' ) {
$items .= "