Answer the question
In order to leave comments, you need to log in
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"> </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"> </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"> </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 ' ' . CHtml::link(tc('Change'), 'javascript:;', array(
'onclick' => '$("#date_end_activity").hide(); $("#set_period_activity").val(1); $("#set_period").show();',
));
echo '</div>';
}
?>
</div>
$rows = HFormEditor::getGeneralFields();
HFormEditor::renderFormRows($rows, $model, $form, $seasonalPricesModel, $callFrom);
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question