Custom Field and Multipage Forms (AJAX)

I created a Custom Field using GF_Field and it seems like the data isn’t being saved when using a Multipage Form using Ajax. It displays properly but when I move forward in the form to the next page it losses its selection (radio field) when I go back to its page. Also, it does not send the field to the form entry/submission. Im currently using this function and using Timber/Twig to render the view.

if (class_exists('GF_Field')) {
	class GF_Field_Service_Scheduler extends GF_Field_Radio {
		public $type = 'service_scheduler';
		
		
 	   	public function get_form_editor_field_title() {
			return esc_attr__('Service Scheduler', 'txtdomain');
		}

		
		public function get_form_editor_field_settings() {
			return [
			'label_setting',
			'description_setting',
			];
		}
		
		public function is_value_submission_array() {
			return true;
		}
		
		public function get_field_input($form, $value = '', $entry = null) {
			if ($this->is_form_editor()) {
				return '';
			}
			
			$products = carbon_get_theme_option('crb_ss_selectable_items');
			$id = (int) $this->id;
			$form_id = $form['id'];
			
			$view = Timber::compile('views/templates/blocks/request-form.twig', array(
				  'products' => $products,
				  'input_id' => $id,
				  'form_id'  => $form_id,
			  ));
			return $view;
			// .. Rest of code for frontend and edit entry here...
		}

	}
	GF_Fields::register( new GF_Field_Service_Scheduler() );
}```

The currently selected choice is stored in the $value param. You’ll need to pass that into your timber compiler so it can ensure the choice is marked as selected in the field markup when the form is redisplayed when paging or when validation errors occur.

Also, you need to make sure that the timber compiler is setting the input name attribute in the markup to input_{$id}. So if the field id is 1 the input name would be input_1

Awesome! The $value param was all that I was missing. Thank you so much!!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.