S
S
sgidlev2016-08-26 23:31:05
Yii
sgidlev, 2016-08-26 23:31:05

How to swap fields in a form in Yii?

Greetings.
I have been struggling with the form for adding an ad on the site for two days now. I can't figure out how to change the place of the form field in the output.
Here is the code:

<div class="tab-pane active" id="tab-main">


<?php 
$callFrom = (isset($callFrom)) ? $callFrom : null;
echo CHtml::hiddenField('is_update', 0);
?>

<?php if(isset($callFrom) && $callFrom == 'guestAdModule' && Yii::app()->user->hasState('guest_ad_sessionid')):?>
  <?php if($model->type != Apartment::TYPE_BUY && $model->type != Apartment::TYPE_RENTING) :?>
    <div class="clear">&nbsp;</div>
      <div class="rowold">
        <label for=""><?php echo tc('Photos for listing'); ?></label>
        <?php
          $this->widget('application.modules.images.components.GuestAdImagesWidget', array(
            'sessionId' => Yii::app()->user->getState('guest_ad_sessionid'),
          ));
        ?>
      </div>
    <div class="clear">&nbsp;</div>
  <?php endif;?>
<?php endif;?>

<?php
$rows = HFormEditor::getGeneralFields();
HFormEditor::renderFormRows($rows, $model, $form, $seasonalPricesModel, $callFrom);

echo '<br/>';


if ($model->type == Apartment::TYPE_CHANGE) {
    echo '<div class="clear">&nbsp;</div>';
    $this->widget('application.modules.lang.components.langFieldWidget', array(
        'model' => $model,
        'field' => 'exchange_to',
        'type' => 'text'
    ));
}

$canSet = $model->canSetPeriodActivity() ? 1 : 0;

echo '<div class="rowold" id="set_period" ' . ( !$canSet ? 'style="display: none;"' : '' ) . '>';
echo $form->labelEx($model, 'period_activity');
echo $form->dropDownList($model, 'period_activity', HApartment::getPeriodActivityList());
echo CHtml::hiddenField('set_period_activity', $canSet);
echo $form->error($model, 'period_activity');
echo '</div>';

if(!$canSet) {
    echo '<div id="date_end_activity"><b>'.Yii::t('common', 'The listing will be active till {DATE}', array('{DATE}' => $model->getDateEndActivityLongFormat())).'</b>';
    echo '&nbsp;' . CHtml::link(tc('Change'), 'javascript:;', array(
            'onclick' => '$("#date_end_activity").hide(); $("#set_period_activity").val(1); $("#set_period").show();',
        ));
    echo '</div>';
}

?>

</div>

Here is the page: krim-zemlya.com/guestad/add
I realized that this piece is responsible for the output of the fields:
$rows = HFormEditor::getGeneralFields();
HFormEditor::renderFormRows($rows, $model, $form, $seasonalPricesModel, $callFrom);

I looked in the controller HformEditor and HformDesigner, I can’t post their codes, because exceed the allowed number of characters.
And further where to dig I will not understand.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sgidlev, 2016-08-29
@sgidlev

The solution was buried in the admin panel.

M
Maxim Timofeev, 2016-08-27
@webinar

1. The presence of CHtml indicates that it is yii1, not yii2
2. You have a bunch of HFormEditor-type components that are not standard for yii. Therefore, you must either give a link to their repository or read the docks for them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question