pkjoshi
(Info)
November 3, 2014, 4:04pm
1
I have just copied the code for yii2 tabs guide and want to include a Form in the first Tab and a Gridview in the second tab.
for testing I have edited just one line in the code with ‘<?= “test”’ , but the same is not working
here is the full code:
<?php
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => '<?= "test"',
'active' => true
],
[
'label' => 'Two',
'content' => 'Anim pariatur cliche...',
//'headerOptions' => [...],
'options' => ['id' => 'myveryownID'],
],
[
'label' => 'Dropdown',
'items' => [
[
'label' => 'DropdownA',
'content' => 'DropdownA, Anim pariatur cliche...',
],
[
'label' => 'DropdownB',
'content' => 'DropdownB, Anim pariatur cliche...',
],
],
],
],
]);
?>
Lordfef
(Account)
November 4, 2014, 4:10pm
2
'content' => '<?= "test"',
with this code you are telling to display not only "test" but also "<?= " because you must specify a string.
In this case you must write
'content' => 'test',
or if you have a long string you can do:
<?php
$content = "
<div>
<p>
test
</p>
</div>
";
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => $content,
'active' => true
],
The problem i see in your code is that you are into
<?php
tag and you want to create another tag
<?=
but into php tag you must use
echo 'test';
pkjoshi
(Info)
November 4, 2014, 5:24pm
3
The problem i see in your code is that you are into
<?php
tag and you want to create another tag
<?=
but into php tag you must use
echo 'test';
Yes I have also tried exactly as suggested by you i.e.
echo 'test';
but then I am getting the error:
syntax error, unexpected ‘echo’ (T_ECHO)
this the exact code:
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => echo 'test';,
'active' => true
],
Lordfef
(Account)
November 4, 2014, 6:24pm
4
but i think you are doing confusion. Look at this code
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => echo 'test';,
'active' => true
],
the first command you do is ECHO, so all of the setting/function you will insert after echo, must return simply a STRING. You can’t repeat echo inside echo!
'content' => echo 'test';,
Here there is a BIG mistake because is the same error of write:
echo echo 'test';;
Let me explain basic concept:
Your web page is HTML.
HTML contain many tag as <div> <form> <table> etc…
There is one tag <?php ?> that tell to the web-server do compile the php code inside the tag.
So if you write
<p>
Hello Word!
</p>
is exactly to write
<p>
<?php
$var = 'Hello';
echo $var . ' World!';
?>
</p>
Your Error is that you are doing is something like this:
<p>
<?php
$var = 'Hello';
echo $var . echo 'test'; ;
?>
</p>
I hope you understand my poor english
pkjoshi
(Info)
November 4, 2014, 7:34pm
5
but i think you are doing confusion. Look at this code
echo Tabs::widget([
'items' => [
[
'label' => 'One',
'content' => echo 'test';,
'active' => true
],
the first command you do is ECHO, so all of the setting/function you will insert after echo, must return simply a STRING. You can’t repeat echo inside echo!
'content' => echo 'test';,
Here there is a BIG mistake because is the same error of write:
echo echo 'test';;
Let me explain basic concept:
Your web page is HTML.
HTML contain many tag as <div> <form> <table> etc…
There is one tag <?php ?> that tell to the web-server do compile the php code inside the tag.
So if you write
<p>
Hello Word!
</p>
is exactly to write
<p>
<?php
$var = 'Hello';
echo $var . ' World!';
?>
</p>
Your Error is that you are doing is something like this:
<p>
<?php
$var = 'Hello';
echo $var . echo 'test'; ;
?>
</p>
I hope you understand my poor english
Thanks I got it now, what I was doing wrong.