handling rating forms change on lables and functionnalities
This commit is contained in:
parent
c2873cbcc6
commit
f309a6c2bb
|
|
@ -6,35 +6,34 @@ if (class_exists('GF_Field')) {
|
||||||
|
|
||||||
public $choices = [
|
public $choices = [
|
||||||
[
|
[
|
||||||
'text' => 'Non',
|
'text' => 'Pas du tout utile',
|
||||||
'value' => 1,
|
'value' => 1,
|
||||||
'isSelected' => false,
|
'isSelected' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => 'Un peu',
|
'text' => 'Peu utile',
|
||||||
'value' => 2,
|
'value' => 2,
|
||||||
'isSelected' => false,
|
'isSelected' => false,
|
||||||
'price' => ''
|
'price' => ''
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => 'Moyen',
|
'text' => 'Moyennement utile',
|
||||||
'value' => 3,
|
'value' => 3,
|
||||||
'isSelected' => false,
|
'isSelected' => false,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'text' => 'Beaucoup',
|
'text' => 'Assez utile',
|
||||||
'value' => 4,
|
'value' => 4,
|
||||||
'isSelected' => false,
|
'isSelected' => false,
|
||||||
],
|
],
|
||||||
|
|
||||||
[
|
[
|
||||||
'text' => 'Parfait',
|
'text' => 'Très utile',
|
||||||
'value' => 5,
|
'value' => 5,
|
||||||
'isSelected' => false,
|
'isSelected' => false,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
public function get_form_editor_field_title()
|
public function get_form_editor_field_title()
|
||||||
{
|
{
|
||||||
return esc_attr__('Notation Satisfaction Homegrade', 'homegrade-theme__texte-fonctionnel');
|
return esc_attr__('Notation Satisfaction Homegrade', 'homegrade-theme__texte-fonctionnel');
|
||||||
|
|
|
||||||
|
|
@ -2,31 +2,25 @@
|
||||||
|
|
||||||
function populate_note_comment_based_on_rating($form)
|
function populate_note_comment_based_on_rating($form)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if ($form['id'] != 24) return;
|
if ($form['id'] != 24) return;
|
||||||
|
|
||||||
$commented_string_notes = array(
|
|
||||||
1 => 'Non',
|
|
||||||
2 => 'Un peu',
|
|
||||||
3 => 'Moyen',
|
|
||||||
4 => 'Beaucoup',
|
|
||||||
5 => 'Parfait'
|
|
||||||
);
|
|
||||||
|
|
||||||
// ## GLOBAL RATING
|
|
||||||
$original_global_rating_field_id = 16;
|
|
||||||
$hidden_copy_global_rating_field_id = 20;
|
|
||||||
$global_user_rating = rgpost("input_{$original_global_rating_field_id}");
|
|
||||||
|
|
||||||
$stringified_global_rating = isset($commented_string_notes[$global_user_rating]) ? $commented_string_notes[$global_user_rating] : '';
|
|
||||||
$_POST["input_{$hidden_copy_global_rating_field_id}"] = $stringified_global_rating;
|
|
||||||
|
|
||||||
|
|
||||||
// ## INFORMATION ACCESSIBILITY RATING
|
foreach ($form['fields'] as $key => $field) {
|
||||||
$original_information_accessibility_rating_field_id = 15;
|
if ($field->type !== "homegrade-rating" && $field->type !== "classic-rating") continue;
|
||||||
$hidden_copy_information_accessibility_rating_field_id = 21;
|
|
||||||
$information_accessibility_user_rating = rgpost("input_{$original_information_accessibility_rating_field_id}");
|
|
||||||
|
|
||||||
$stringified_information_accessibility_rating = isset($commented_string_notes[$information_accessibility_user_rating]) ? $commented_string_notes[$information_accessibility_user_rating] : '';
|
$user_rating = rgpost("input_{$field->id}");
|
||||||
$_POST["input_{$hidden_copy_information_accessibility_rating_field_id}"] = $stringified_information_accessibility_rating;
|
|
||||||
|
$nextHiddenLabelField = $form["fields"][$key + 1] ?? null;
|
||||||
|
$stringified_information_accessibility_rating = isset($field["choices"][$user_rating - 1]['text']) ? $field["choices"][$user_rating - 1]['text'] : '';
|
||||||
|
|
||||||
|
|
||||||
|
if (!$nextHiddenLabelField || $nextHiddenLabelField->type !== "hidden" || !$stringified_information_accessibility_rating) continue;
|
||||||
|
|
||||||
|
|
||||||
|
$_POST["input_{$nextHiddenLabelField->id}"] = $stringified_information_accessibility_rating;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
add_action('gform_pre_submission', 'populate_note_comment_based_on_rating');
|
add_action('gform_pre_submission', 'populate_note_comment_based_on_rating');
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,8 @@
|
||||||
@apply pb-6 !text-2xl text-center;
|
@apply pb-6 !text-2xl text-center;
|
||||||
}
|
}
|
||||||
.gfield_radio {
|
.gfield_radio {
|
||||||
@apply grid grid-cols-2 sm:flex justify-between max-w-lg text-center mx-auto;
|
@apply grid grid-cols-2 sm:flex justify-between max-w-lg text-center mx-auto items-start;
|
||||||
|
@apply gap-0 sm:gap-4 md:gap-6;
|
||||||
|
|
||||||
@media screen and (max-width: 400px) {
|
@media screen and (max-width: 400px) {
|
||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,15 @@
|
||||||
@apply pb-6 !text-2xl text-center;
|
@apply pb-6 !text-2xl text-center;
|
||||||
}
|
}
|
||||||
.gfield_radio {
|
.gfield_radio {
|
||||||
@apply grid sm:flex justify-between max-w-lg text-center mx-auto;
|
@apply grid sm:flex md:justify-between max-w-lg text-center mx-auto items-start;
|
||||||
|
@apply gap-0 sm:gap-2 md:gap-6;
|
||||||
|
|
||||||
@media screen and (max-width: 400px) {
|
@media screen and (max-width: 400px) {
|
||||||
grid-template-columns: auto auto;
|
grid-template-columns: auto auto;
|
||||||
width: fit-content;
|
width: fit-content;
|
||||||
column-gap: 1rem;
|
column-gap: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.gchoice {
|
.gchoice {
|
||||||
@apply flex flex-col justify-center items-center;
|
@apply flex flex-col justify-center items-center;
|
||||||
&:last-child {
|
&:last-child {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user