How to do Nesting of html elements in cakePHP 3 syntax? - cakephp-3.x

I want to know that how to write the below given html code in cakePHP 3 syntax :-
<a href="#" class="sidebar-toggle" data-toggle="push-menu" role="button">
<span class="sr-only">Toggle navigation</span>
</a>

you can simply put the span tag inside the html link this way
<?= $this->Html->link(
'<span class="sr-only">Toggle navigation</span>',
'#', [
'class' => "sidebar-toggle",
'data-toggle' => "push-menu",
'role' => "button",
'escape' => false
]); ?>
or you can use the tag method to create the span tag
<?= $this->Html->link(
$this->Html->tag('span', 'Toggle navigation', ['class'=>"sr-only"]),
'#', [
'class' => "sidebar-toggle",
'data-toggle' => "push-menu",
'role' => "button",
'escape' => false
]); ?>

Related

Missing Keys: title

I installed Bagisto and everything run smoothly until I added Laravel AliExpress Dropshipping.
There's error :
Webkul\Ui\Exceptions\ActionKeyException
Missing Keys: title (View: /Applications/MAMP/htdocs/bagisto/packages/Webkul/Dropship/src/Resources/views/admin/products/index.blade.php)
What does Missing Keys: title means
#extends('admin::layouts.content')
#section('page_title')
{{ __('dropship::app.admin.products.title') }}
#stop
#section('content')
<h1>
{{ __('dropship::app.admin.products.title') }}
</h1>
<div class="page-action">
<button class="btn btn-lg btn-primary" style="display: none">
{{ __('dropship::app.admin.products.import-btn-title') }}
</button>
</div>
I had a similar problem with Bagisto Bulk Upload extension. To fix it I added the 'title' key to both addAction at extension's DataGrid class.
public function prepareActions() {
$this->addAction([
'type' => 'Edit',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.edit',
'icon' => 'icon pencil-lg-icon',
'title' => ''
]);
$this->addAction([
'type' => 'Delete',
'method' => 'GET', // use GET request only for redirect purposes
'route' => 'marketplace.bulkupload.profile.delete',
'icon' => 'icon trash-icon',
'title' => ''
]);
$this->enableAction = true;
}
Source

How can I create popup form in Yii2

I want a way to create popup form when I press the button using Ajax and bootstrap
and how to create modal for it with bootstrap
use yii\bootstrap\Modal;
you can do it like it, call a view/action in modal
<?php
Modal::begin([
'toggleButton' => [
'label' => '<i class="fa fa-plus"></i> Add',
'class' => 'btn btn-success'
],
'closeButton' => [
'label' => 'Close',
'class' => 'btn btn-danger btn-sm pull-right',
],
'size' => 'modal-lg',
]);
$myModel = new \frontend\models\SomeModel;
echo $this->render('/someview/create', ['model' => $myModel]);
Modal::end();
?>
reference Render Form in popup via AJAX

yii2 file extension validation not works

I have rule in my model like this
public function rules()
{
return [
[['tbl_data_induk_mahasiswa_id'], 'required'],
[['tbl_data_induk_mahasiswa_id'], 'integer'],
[['nama'], 'file','extensions'=>'png,jpg','maxSize' => 1024000,'tooBig' => 'Size maksimum adalah 1 MB'],
[['nama'], 'string', 'max' => 300],
[['tbl_data_induk_mahasiswa_id'], 'unique'],
[['tbl_data_induk_mahasiswa_id'], 'exist', 'skipOnError' => true, 'targetClass' => TblDataIndukMahasiswa::className(), 'targetAttribute' => ['tbl_data_induk_mahasiswa_id' => 'id']],
];
}
i have form like this
<?php
use yii\helpers\Html;
//use yii\widgets\ActiveForm;
echo Html::beginForm(
['mahasiswa-foto-biodata/update'],
'post',
['enctype' => 'multipart/form-data'] //if you want to upload file with post
); ?>
<div class="form-group form-file-upload form-file-multiple">
<?= Html::activeFileInput(
$model,
'nama',
['class' => 'inputFileHidden', 'multiple' => '']
); ?>
<div class="input-group">
<?= Html::activeTextInput(
$model,
'nama',
[
'class' => 'form-control inputFileVisible',
'placeholder' => 'Single File',
]
); ?>
<span class="input-group-btn">
<button type="button" class="btn btn-fab btn-round btn-primary">
<i class="material-icons">attach_file</i>
</button>
</span>
</div>
</div>
<div class="form-group">
<?= Html::submitButton('Save', ['class' => 'btn btn-success']) ?>
</div>
<?= Html::endForm(); ?>
I can not use activeForm widget because i must create html form that suit with my template, the form is work, the file succesfull uploaded, the problem is every tipe file is success uploaded, not just only png or jpg, but if i change the max rule for nama to [['nama'], 'string', 'max' => 2],then i upload a file that have name's length more than two the file can not be uploaded.
Any help?
Please check your form, you have 02 types of input with the same name ("nama"). One is "file", one is "text"
I think it is the reason that make your form does not works correctly!

Ck editor code not working when we edit the content in codeigniter

<div class="form-group">
<?php echo form_textarea(array('name' => 'txtdescription', 'id' => 'desc', 'class' => "ckeditor", 'value' => set_value('txtdescription', htmlspecialchars_decode($desc)))); ?>
</div>
This is my view code when we get data from db
Add 3 argument for set_value.
Try this:
<div class="form-group">
<?php echo form_textarea(array('name' => 'txtdescription', 'id' => 'desc', 'class' => "ckeditor", 'value' => set_value('txtdescription', $desc,false))); ?>
</div>

Creating image link creates a path adding controller name

I am trying to implement a image gallery in cakephp with below structure:
echo $this->Html->link(
$this->Html->image('gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
array('class'=>'img img-responsive')
),
'gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
array(
'class' => 'col-sm-4',
'escape' => false,
'data-toggle' => 'lightbox',
'data-gallery' => 'multiimages',
)
);
But the above script outputs HTML:
<a href="/nitish/cakem/galleries/gallery/fashion/fashion-photography-guwahati-big-4.jpg" class="col-sm-4" data-toggle="lightbox" data-gallery="multiimages">
<img src="/nitish/cakem/img/gallery/fashion/fashion-photography-guwahati-4.jpg" class="img img-responsive" alt="" />
</a>
As you can see in the anchor path, additional galleries directory is added. How to remove this ?
NB: galleries is my controller name
Strart you paths with a slash:
echo $this->Html->link(
$this->Html->image('/gallery/fashion/fashion-photography-guwahati-'.$i.'.jpg',
array('class'=>'img img-responsive')
),
'/gallery/fashion/fashion-photography-guwahati-big-'.$i.'.jpg',
array(
'class' => 'col-sm-4',
'escape' => false,
'data-toggle' => 'lightbox',
'data-gallery' => 'multiimages',
)
);

Resources