From 44d0417c92d41481db178f76a529ea1b16e654e2 Mon Sep 17 00:00:00 2001
From: dyszczo <krzysztof.dyszczyk@gmail.com>
Date: Tue, 26 May 2020 10:53:08 +0100
Subject: [PATCH] fix for fields data when render_fields

---
 src/Form/FormWithFields.php | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/src/Form/FormWithFields.php b/src/Form/FormWithFields.php
index a0d7398..490032c 100644
--- a/src/Form/FormWithFields.php
+++ b/src/Form/FormWithFields.php
@@ -135,7 +135,8 @@ class FormWithFields implements Form, ContainerForm, FieldProvider {
 	 * @return string
 	 */
 	public function render_fields( Renderer $renderer ) {
-		$content = '';
+		$content     = '';
+		$fields_data = $this->get_data();
 		foreach ( $this->get_fields() as $field ) {
 			$content .= $renderer->render( $field->should_override_form_template() ? $field->get_template_name() : 'form-field',
 				[
@@ -154,15 +155,11 @@ class FormWithFields implements Form, ContainerForm, FieldProvider {
 	 * @inheritDoc
 	 */
 	public function render_form( Renderer $renderer ) {
-		$fields_data = $this->get_data();
-
 		$content = $renderer->render( 'form-start', [
 			'method' => 'POST',
 			'action' => '',
 		] );
-
 		$content .= $this->render_fields( $renderer );
-
 		$content .= $renderer->render( 'form-end' );
 
 		return $content;
-- 
GitLab