Validating input without model

A have a simple datepicker in a frontend view, These dates must be passed to the controller that will make a call on a method of an API. How valid the inputs?


<?= Html::beginForm(); ?>

                    <div class="col-md-1">

                        <?= Html::label('Start date', 'startDate') ?>

                    </div>

                    <div class="col-md-2">

                        <?= DatePicker::widget([

                            'name'  => 'startDate',

                            'id'  => 'startDate',

                            'language' => 'pt-BR',

                            'value' => date('Y-m-d', strtotime('-7 days')),

                            // 'dateFormat' => 'dd/MM/yyyy',

                             'clientOptions' => ['yearRange' => '2005:+0'],

                            'options' => ['class' => 'form-control ga-dates', 'maxlength' => '10']

                        ]); ?>            

                    </div>

                    <div class="col-md-1">

                        <?= Html::label('End date', 'endDate') ?>

                    </div>

                    <div class="col-md-2">

                        <?= DatePicker::widget([

                            'name'  => 'endDate',

                            'id'  => 'endDate',

                            'language' => 'pt-BR',

                            'value' => date('Y-m-d'),

                            // 'dateFormat' => 'dd/MM/yyyy',

                            

                            'options' => ['class' => 'form-control ga-dates', 'maxlength' => '10']

                        ]); ?>

                    </div>

                    <div class="col-md-2">

                        <?= Html::submitButton('Filtrar', ['class' => 'btn btn-primary']) ?>

                    </div>

                    <?= Html::endForm() ?>

Try with javascript in onSubmit event

I think it… But in backend, i leave without validation?

Use a model - it does not have to be an ActiveRecord model. A regular ActiveForm model will do.

jacmoe, you saying to use a model with property formName()-?

can show me a little example?

You can also use DynamicModel: http://www.yiiframework.com/doc-2.0/yii-base-dynamicmodel.html