-
-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle saving related values if passed as an array of information #4917
base: main
Are you sure you want to change the base?
Conversation
@sc0ttkclark Could you give me a bit more info about the nature of this PR? |
@JoryHogeveen To test this, use the example code. Perhaps we can write tests based on those two? |
Tried example 1 without success. $pod = pods( 'post', 1 ); // The first post; Hello World.
$pod->save(
[
// Multi-select relationship field titled "other_posts".
'other_posts' => [
[
'post_title' => 'Another Post',
'post_content' => '',
'favorite_color' => '#33ee33', // Color Picker field.
],
],
]
); Expectation was that it would create another post and assign it to the relationship field on post ID |
@sc0ttkclark @pdclark 1: Working code: $pod = pods( 'post', 1 ); // The first post; Hello World.
$pod->save(
[
// Multi-select relationship field titled "other_posts".
'other_posts' => [
[
'post_status' => 'publish',
'post_type' => 'post',
'post_title' => 'Another Post',
'post_content' => '',
'favorite_color' => '#33ee33', // Color Picker field.
],
],
]
); |
Great thanks Jory. <?php
add_action( 'init', function(){
$pod = pods( 'post', 1 ); // The first post; Hello World.
$pod->save(
[
// Multi-select relationship field titled "other_posts".
'other_posts' => [
[
'post_status' => 'publish',
'post_type' => 'post',
'post_title' => 'Another Post',
'post_content' => '',
'favorite_color' => '#33ee33', // Color Picker field.
],
],
]
);
}); |
Examples below use a "books" pick field, multiple select, related to a "book" custom post type created or extended by Pods).
Example 1
Expectation would be that the above code would save a new value for the related book field.
Example 2
Expectation would be that the above code would update the data for the the related book field.