Skip to content

Commit

Permalink
simplify form view(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
eluhr committed Mar 27, 2023
1 parent 4cd779f commit f33a31c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 25 deletions.
3 changes: 1 addition & 2 deletions src/generators/crud/default/views/_form-fields.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* @var <?= ltrim($generator->modelClass, '\\') ?> $model
* @var yii\widgets\ActiveForm $form
*/

?>
<?php
foreach ($safeAttributes as $attribute) {
echo "\n\n\t<!-- attribute $attribute -->\n";
echo "\n\n<!-- attribute $attribute -->\n";
$prepend = $generator->prependActiveField($attribute, $model);
$field = $generator->activeField($attribute, $model);
$append = $generator->appendActiveField($attribute, $model);
Expand Down
30 changes: 7 additions & 23 deletions src/generators/crud/default/views/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,32 +49,18 @@
);
?>

<div class="">
<?php echo "<?php \$this->beginBlock('main'); ?>\n"; ?>
<div class="form-fields">
<?php echo "<?php echo \$this->render('_form-fields', ['form' => \$form, 'model' => \$model])?>\n"?>
</div>
<?php echo '<?php $this->endBlock(); ?>'; ?>

<?php
$label = substr(strrchr($model::class, '\\'), 1);

$items = <<<EOS
[
'label' => Yii::t('$generator->modelMessageCategory', '$label'),
'content' => \$this->blocks['main'],
'active' => true,
],
EOS;
?>

<?=
"<?=
$label = $generator->generateString(substr(strrchr($model::class, '\\'), 1));
echo "<?=
Tabs::widget(
[
'encodeLabels' => false,
'items' => [
$items
[
'label' => $label,
'content' => \$this->render('_form-fields', ['form' => \$form, 'model' => \$model]),
'active' => true,
]
]
]
);
Expand All @@ -97,7 +83,5 @@

<?= '<?php ' ?>ActiveForm::end(); ?>

</div>

</div>

0 comments on commit f33a31c

Please sign in to comment.