Payload Information inside main.js or frontend.js

Hi All,

I’m trying to create a multi ticklist using a relation to an object where it will then use all the booleans as questions.

Running through the questions I’ve been creating the html inside main.js see below:

		checkbox_choices += `
				<div class="radio_choices-row">
					<label class="custom-control custom-checkbox form-text">`
			if (return_values[checkbox_properties[key]]){
				checkbox_choices += `
						<input :name="mats.input_name + '[${checkbox_properties[key]}]'" class="col-form-value valid_boolean custom-control-input input_boolean custom-checkbox" type="checkbox" checked="checked">`
			}
			else{ 
				checkbox_choices += `
						<input :name="mats.input_name + '[${checkbox_properties[key]}]'" class="col-form-value valid_boolean custom-control-input input_boolean custom-checkbox" type="checkbox">`
			}
				checkbox_choices += `
						<span class="custom-control-indicator"></span>								
						<span class="custom-control-description">${label}</span>
					</label>
				</div>`

When :name=“mats.input_name + ‘[${checkbox_properties[key]}]’” is sent to the html it doesn’t resolve the html. this would show:

instead of:

Does anyone know how to get the name=“payload[PAG0000664FEFFD1][PWG0002173FEFFD1][PCL0004552FEFFD1] and the data-v-bd402bd6=”" either in main.js or frontend.js?

Thanks

Hi,

I’m assuming you are doing this in a presenter, have a look at get_input_attributes() method, that will contain all that you need, which you can then pass along to the frontend.

 Array
(
    [class] => col-form-value required col-form-value valid_string valid_max_length form-control
    [data-max_length] => 255
    [name] => payload[PAG0000002EFCAE9][PWG0000004EFCAE9][PCL0000507EFCAE9][formtable][C_5fe35f7ce2076][PCF0000753EFCAE9]
    [id] => payload[PAG0000002EFCAE9][PWG0000004EFCAE9][PCL0000507EFCAE9][formtable][C_5fe35f7ce2076][PCF0000753EFCAE9]
    [aria-describedby] => label_payload[PAG0000002EFCAE9][PWG0000004EFCAE9][PCL0000507EFCAE9][formtable][C_5fe35f7ce2076][PCF0000753EFCAE9]
    [for] => payload[PAG0000002EFCAE9][PWG0000004EFCAE9][PCL0000507EFCAE9][formtable][C_5fe35f7ce2076][PCF0000753EFCAE9]
)

Hey that’s definitely the data I’m looking for but I’m doing it from a widget.

I have managed to find the page ref and copied the pwg and pcl from inspecting the html, and the prepare save data works this way. I can’t find these pwg or pcl using anything in cs or widget

Hey,

Yeah I don’t think these are exposed in the backend, you can get them in the frontend.

let input_name = this.mats.input_name;
let pageId = /(?<=\[)(PAG.*?)(?=\])/.exec(input_name);
let widgetGroup = /(?<=\[)(PWG.*?)(?=\])/.exec(input_name);
let cellId = /(?<=\[)(PCL.*?)(?=\])/.exec(input_name);

Hey,

That’s exactly what I was looking for thankyou