diff --git a/src/Form/FormWithFields.php b/src/Form/FormWithFields.php index 0e549baf465a8b1c7818e708f1f62b62c2110a24..a0d739841c948779b1eb2dfd89e0d94e5e86dc38 100644 --- a/src/Form/FormWithFields.php +++ b/src/Form/FormWithFields.php @@ -35,7 +35,7 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { /** * FormWithFields constructor. * - * @param array $fields Form fields. + * @param array $fields Form fields. * @param string $form_id Unique form id. */ public function __construct( array $fields, $form_id = 'form' ) { @@ -128,16 +128,14 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { } /** - * @inheritDoc + * Renders only fields without form. + * + * @param Renderer $renderer + * + * @return string */ - public function render_form( Renderer $renderer ) { - $fields_data = $this->get_data(); - - $content = $renderer->render( 'form-start', [ - 'method' => 'POST', - 'action' => '', - ] ); - + public function render_fields( Renderer $renderer ) { + $content = ''; foreach ( $this->get_fields() as $field ) { $content .= $renderer->render( $field->should_override_form_template() ? $field->get_template_name() : 'form-field', [ @@ -149,6 +147,22 @@ class FormWithFields implements Form, ContainerForm, FieldProvider { ] ); } + return $content; + } + + /** + * @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;