Christian Posted July 14, 2014 Share Posted July 14, 2014 Hi! I have a problem dealing with dynamic saving of content on API. I never encounter any problem when I save a page when static so there is no problem on fetching a new data. Dynamic field name that is not working. foreach( $page->fields as $field ) { if( ! in_array($field->type, $ignore_field_type) ) { $field_name = $field->name; $revise_page->$field_name = $page->get($field->name); } } Static field name that is working. $revise_page->site_metadata = $page->get("site_metadata"); $revise_page->body = $page->get("body"); Link to comment Share on other sites More sharing options...
Christian Posted July 14, 2014 Author Share Posted July 14, 2014 Fixed. Just have to add curly braces. foreach( $page->fields as $field ) { if( ! in_array($field->type, $ignore_field_type) ) { $field_name = $field->name; $revise_page->{$field_name} = $page->get($field->name); } } 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now