I have a list of “Room” options set up in the Options tab. I want the client to be able to manage the list from Options and then the list to appear on the Rooms page so they can select which options are available for that particular room. If the client update the main list of options form the Options page, they would need to update on the Rooms page.
I have a Repeater called “Room features / room_features” already set up and is working as expected on the Options page.
What is shown in the Options page:
Repeater:
Row 1:
Text – Title – ‘Beds’<--- This is basically a label for that section and is only editable from the Options page.
Repeater – Options: 2 beds, 3 beds etc…
Row 2:
Text – Title – ‘Size’<--- This is basically a label for that section and is only editable from the Options page.
Repeater – Options: 340 Square Feet , 640 Square Feet etc…
What I would like to show on the Rooms page:
Group:
Set 1: each set built from the Repeater
Visibility – Yes/No
Title – Beds – Not editable
Options – Checkboxes created by the Repeater
Set 2: each set built from the Repeater
Visibility – Yes/No
Title – Beds – Not editable
Options – Checkboxes created by the Repeater
Below is the code I have so far. The rows are being built and the title is being populated. "var_dump($options_value);" is outputting the repeater values that would create the checkboxes but I can't figure out how to add the choices. key=field_602ad24de4cfd is the repeater on the Rooms page.
function my_acf_set_repeater( $value, $post_id, $field ){
$value = array();
// this is the main repeater from Options
$settings_values = get_field('room_features','option');
foreach( $settings_values as $settings_value ){
// This is setting the title
$value[]= array('field_602c2e8c5f28f' => $settings_value['title']);
// All of the options
$options_values = $settings_value['items'];
foreach( $options_values as $options_value ){
var_dump($options_value);
}
}
return $value;
}
add_filter('acf/load_value/key=field_602ad24de4cfd', 'my_acf_set_repeater', 10, 3);
Is the 1st image below you can see the 1st 3 arrays are what's in row 1 and the other 2 are in row 2. That is what is showing on the Rooms page.
The second image is how the Options page looks now.
Is this even possible? Thanks in advance!!!
Aucun commentaire:
Enregistrer un commentaire