/** * Add `choice_display` setting to the field * * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context * @param string $input_type * * @since 1.17 * * @return array */ function field_options($field_options, $template_id, $field_id, $context, $input_type) { // Set the $_field_id var $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type); if ($this->is_choice_value_enabled()) { $field_options['choice_display'] = array('type' => 'radio', 'value' => 'value', 'label' => __('What should be displayed:', 'gravityview'), 'desc' => __('This input has a label and a value. What should be displayed?', 'gravityview'), 'choices' => array('value' => __('Value of the input', 'gravityview'), 'label' => __('Label of the input', 'gravityview'))); } return $field_options; }
/** * Add `choice_display` setting to the field * * @param array $field_options * @param string $template_id * @param string $field_id * @param string $context * @param string $input_type * * @since 1.17 * * @return array */ function field_options($field_options, $template_id, $field_id, $context, $input_type) { // Set the $_field_id var $field_options = parent::field_options($field_options, $template_id, $field_id, $context, $input_type); // It's not the parent field; it's an input if (floor($field_id) !== floatval($field_id)) { if ($this->is_choice_value_enabled()) { $desc = esc_html__('This input has a label and a value. What should be displayed?', 'gravityview'); $default = 'value'; $choices = array('tick' => __('A check mark, if the input is checked', 'gravityview'), 'value' => __('Value of the input', 'gravityview'), 'label' => __('Label of the input', 'gravityview')); } else { $desc = ''; $default = 'tick'; $choices = array('tick' => __('A check mark, if the input is checked', 'gravityview'), 'label' => __('Label of the input', 'gravityview')); } $field_options['choice_display'] = array('type' => 'radio', 'class' => 'vertical', 'label' => __('What should be displayed:', 'gravityview'), 'value' => $default, 'desc' => $desc, 'choices' => $choices); } return $field_options; }
function field_options($field_options, $template_id = '', $field_id = '', $context = '', $input_type = '') { // Set variables parent::field_options($field_options, $template_id, $field_id, $context, $input_type); if ('edit' === $context) { return $field_options; } /** * Set default date format based on field ID and Form ID */ add_filter('gravityview_date_format', array($this, '_filter_date_display_date_format')); $this->add_field_support('date_display', $field_options); remove_filter('gravityview_date_format', array($this, '_filter_date_display_date_format')); return $field_options; }