Good day!
my code
<!--app/views/site/index.php-->
use yii\helpers\Html;
use yii\bootstrap\Carousel;
use yii\bootstrap\Modal;
use app\models\ContactForm;
use yii\captcha\Captcha;
use app\models\Tariffs;
use app\models\Blocks;
<div id="my-index-internet">
<div class="my-internet">internet</div>
<div class="row">
<?php
Blocks::renderBlock('internet', 'lunohod');
?>
</div>
</div>
<!--app/models/Blocks.php-->
<?php
namespace app\models;
use yii\bootstrap\Modal;
use app\models\Tariffs;
class Blocks
{
/**
* @param $usluga
* @param $tariff_name
*/
public static function renderBlock($usluga, $tariff_name)
{
$render_block = "
<div class='my-tariff col-xs-12 col-sm-5 col-md-4 col-lg-3'>
<div class='thumbnail'>
<div class='my-".$usluga."-buttons'>
".
Modals::renderModal($usluga, $tariff_name)
."
</div>
</div>
</div>
";
echo $render_block;
}
}
<!--app/models/Modals.php-->
<?php
namespace app\models;
use yii\bootstrap\Modal;
use app\models\Tariffs;
class Modals
{
/**
* @param $usluga
* @param $tariff_name
*/
public static function renderModal($usluga, $tariff_name)
{
Modal::begin([
'bodyOptions' => [
'class' => 'my-modal-' . $usluga,
],
'header' => $tariff_name,
'toggleButton' => [
'label' => 'Подробнее',
'tag' => 'button',
'class' => 'btn my-btn-default',
],
'footer' => 'footer',
]);
echo Tariffs::lunohod_detail();
Modal::end();
Modal::begin([
'bodyOptions' => [
'class' => 'my-modal-connect',
],
'header' => '',
'toggleButton' => [
'label' => 'Подключиться',
'tag' => 'button',
'class' => 'btn my-btn-success',
],
]);
ContactForm::actionMail();
Modal::end();
}
}
what result in fact
<div class="my-internet">internet</div>
<div class="row">
<button type="button">
<div class="my-tariff col-xs-12 col-sm-5 col-md-4 col-lg-3">
etc
what should be the result
<div class="my-internet">internet</div>
<div class="row">
<div class="my-tariff col-xs-12 col-sm-5 col-md-4 col-lg-3">
<div class="thumbnail">
<button type="button">
etc
Why is the button that was called inside the diva displayed next to it, and even more so before it?
I have been doing this recently, but I can’t even imagine how to formulate this problem for Google!
I’m found my mistake: when i declaration $render_block, inside this call Modals::renderModal, and only then “echo $render_block”. I had to divide one function into 3 functions and call them in order. Now ok.