public function run()
 {
     $flightForm = new FlightForm();
     if (isset($_GET['FlightForm'])) {
         $flightForm->attributes = $_GET['FlightForm'];
         if (isset($_GET['RouteForm'])) {
             foreach ($_GET['RouteForm'] as $route) {
                 $newRoute = new RouteForm();
                 $newRoute->attributes = $route;
                 $flightForm->routes[] = $newRoute;
             }
         }
         if ($flightForm->validate()) {
             $result = MFlightSearch::getAllPricesAsJson($flightForm);
             echo $result;
         } else {
             throw new CHttpException(500, CHtml::errorSummary($flightForm));
         }
         Yii::app()->end();
     } else {
         throw new CHttpException(404);
     }
 }
Example #2
0
<?php

$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array('id' => 'flight-form', 'enableAjaxValidation' => true, 'htmlOptions' => array('enctype' => 'multipart/form-data')));
?>

    <?php 
$this->widget('frontend.widgets.aviaSearch.AviaSearchWidget', array('model' => $model, 'attribute' => 'routes'));
?>

    <?php 
echo $form->radioButtonListInlineRow($model, 'flightClass', $model->getPossibleFlightClasses());
?>
    <?php 
echo $form->dropDownListRow($model, 'adultCount', FlightForm::getPossibleAdultCount());
?>
    <?php 
echo $form->dropDownListRow($model, 'childCount', $model->getPossibleChildCount());
?>
    <?php 
echo $form->dropDownListRow($model, 'infantCount', $model->getPossibleInfantCount());
?>

    <div class="form-actions">
        <?php 
$this->widget('bootstrap.widgets.BootButton', array('url' => '#popupInfo', 'buttonType' => 'submit', 'type' => 'primary', 'label' => 'Поиск перелёта', 'htmlOptions' => array('id' => 'searchFlight')));
?>
    </div>

<?php 
$this->endWidget();
?>