TypeRocket / core

TypeRocket core source files where all the magic lives.
https://typerocket.com
36 stars 21 forks source link

Adding HTML Between FieldRow Fields #42

Closed eric-michel closed 5 years ago

eric-michel commented 5 years ago

I wanted to be able to add some HTML between fields in the FieldRow class, but when iterating over the array you feed to $form->row() it ignores anything that isn't a Field or FieldColumn. This allows Generator content to be included and adds a helper method on the Form class to make it easy.

Here's an example implementation:

    $test->setTitleForm( function () {
        $form = tr_form();
        $start_date = $form->text( 'Start Date' )->setType( 'date' );
        $to         = $form->rowText( 'to' );
        $end_date   = $form->text( 'End Date' )->setType( 'date' );
        $date_range = $form->row( [
            $start_date,
            $to,
            $end_date
        ] );
        echo $date_range;
    } );

Obviously some CSS needs to be cleaned up to keep the text from being given as much width as the fields (which looks really funny). I'd be happy to do that if this is something you're willing to fold in.