Field loaded when placed into variable
-
Hello,
I’ve just installed this extension, and despite it working well there’s a little bug when you’re loading the field into a variable.
Because instead of placing the field into a variable, the field gets displayed immediately.It doesn’t matter if the field is inside a group or anything, as soon as it’s called it just forces itself onto the front-end.
For example:
Here I’m just preparing a few values to be thrown into the content, with a default fallback. The “cta_form_block” is a group, and has the form in it. As soon as the group is stored into the variable it’s forcing the form to be displayed.//Get the page content $page_form_content = get_field('cta_form_block'); //Here it's already being displayed //Setup new empty fields $form_title = ''; $form_description = ''; $form_form = ''; //Fill the content if( $page_form_content ): //Enter group $form_title = $page_form_content['title']; $form_description = $page_form_content['description']; $form_form = $page_form_content['form']; else: $form_title = $default_title; $form_description = $default_description; $form_form = $default_form; endif; ?>I then figured I might try to make it it’s own field, so I gave it it’s own field. Like so:
$page_form_form = get_field('cta_form_form');That’ll also immediately display the form.
So now I’ll just call the field directly in the content, while I’m generally trying to keep the logic and content seperated as much as possible.
It’s not a dramatic issue, but I thought that it’d be good for you guys to know about this.
The topic ‘Field loaded when placed into variable’ is closed to new replies.