Ecommerce Shopify WordPress Discussion

A dedicated radio button for Gravity Form with the ability to upload an icon

Of course, here's how you can request help for creating a custom radio button field in Gravity Forms that allows uploading an image as an icon next to the label, formatted for Stack Overflow: I'm in need of assistance in creating a custom radio button field for Gravity Forms that enables the upload of an image to serve as an icon next to the label. I'd appreciate any guidance or code examples related to this. Thank you! if (class_exists('GF_Field')) { class CustomRadioButton extends GF_Field { public $type = 'custom_radio_button'; public function get_form_editor_field_title() { return esc_attr__('Custom Radio Button', 'txtdomain'); } public function get_form_editor_button() { return [ 'group' => 'advanced_fields', 'text' => $this->get_form_editor_field_title(), ]; } public function get_form_editor_field_settings() { return [ 'label_setting', 'description_setting', 'choices_setting', // Adding choices setting 'css_class_setting', 'conditional_logic_field_setting', ]; } public function get_field_input($form, $value = '', $entry = null) { if ($this->is_form_editor()) { return ''; } $id = (int) $this->id; $radios = ''; foreach ($this->choices as $key => $choice) { $image_src = isset($choice['image_src']) ? esc_url($choice['image_src']) : ''; $link = isset($choice['link']) ? esc_url($choice['link']) : '#'; $radios .= '<div>'; $radios .= '<input type="radio" id="input_' . $id . '_' . $key . '" name="input_' . $id . '" value="' . $key . '">'; $radios .= '<label for="input_' . $id . '_' . $key . '"><img src="' . $image_src . '" alt="' . $choice['text'] . '"></label>'; $radios .= '</div>'; } return $radios; } } GF_Fields::register(new CustomRadioButton()); }
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.