how to disable breadcrumb for some controllers yii2? - yii2-advanced-app

I want disable or change breadcrumb in Yii2 application. How to do that.I
tried to change with
echo Breadcrumbs::widget([
'itemTemplate' => "<li><i>{link}</i></li>\n", // template for all links
'links' => [
[
'label' => 'Post Category',
'url' => ['post-category/view', 'id' => 10],
'template' => "<li><b>{link}</b></li>\n", // template for this link only
],
['label' => 'Sample Post', 'url' => ['post/edit', 'id' => 1]],
'Edit',
],
]);

Well, first of all change it back to default, which is:
<?= Breadcrumbs::widget([
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
According to yii2 documentation if you set the value for $links to an empty array, breadcrumbs will not show up.
How do you do it?
Check above code , the $links value in being set by $this->params['breadcrumbs'] variable, which is available in every view file. So in your view file just do this:
// empty if you don't want breadcrumbs
$this->params['breadcrumbs'] = [];
Otherwise set some value and your breadcrumbs will show up.

Related

Remove tooltip from kartik/date/datepicker

I use kartik DatePicker in my activeform.
use kartik\date\DatePicker;
My activeform field:
<?= $form->field($model, 'transferred_date')->widget(DatePicker::className(), [
'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select date ...'],
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'todayHighlight' => true
]
])->label('Transferred Date');
?>
When I hover the mouse on calendar icon, it shows a tool tip like this.
I have to remove the tooltip. How can I?
When reading the doc you can read this in the settings:
pickerButton: mixed the calendar picker button configuration - applicable only when type is set to DatePicker::TYPE_COMPONENT_PREPEND or DatePicker::TYPE_COMPONENT_APPEND. This can be one of the following types:
string, if this is a string, it will be displayed as is (and will not be HTML encoded).
boolean, if this is set to false, it will not be displayed.
array, this is the default behavior. If passed as an array, it will be considered as HTML attributes for the picker button addon. The following special keys are recognized:
icon, string the bootstrap glyphicon name/suffix. Defaults to 'calendar'.
title, string|boolean the title to be displayed on hover. Defaults to 'Select date & time'. If this is set to false, it will not be displayed.
So i can say without testing that it should be something like this:
<?= $form->field($model, 'transferred_date')
->widget(DatePicker::className(), [
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'pickerButton' => ['title' => false],
'value' => date('d-M-Y', strtotime('+2 days')),
'options' => ['placeholder' => 'Select date ...'],
'pluginOptions' => [
'format' => 'dd-mm-yyyy',
'todayHighlight' => true
]
])->label('Transferred Date');
?>
So you missed this in the config:
'type' => DatePicker::TYPE_COMPONENT_PREPEND,
'pickerButton' => ['title' => false],

Magento 2 shipping address custom dropdown field value not posting

We have added custom field under shipping address in checkout page.
It's select field and we are showing custom option from database. It's working fine but when we click next and move to payment option to place an order at that time value not posting. selected dropdown value not showing in console.
If we add text field instead then it shows value posted in console. What could be the issue?
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['custom-field'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'id' => 'custom-field',
'options' => $optionarray
],
'dataScope' => 'shippingAddress.custom_attributes.custom_field',
'label' => 'Custom Field',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 250,
'id' => 'custom-field'
];
return $jsLayout;
Any help would be appreciated.

Yii2 Filtering Gridview within Modal Dialog?

i've been trying to create yii\jui\Dialog that is triggered on button click in the form view. the Dialog itself will contain a Gridview Widget within it using Yii 2.0.
i have managed to create the dialog and fill it with the Gridview widget. the only problem that i encounter is that the Gridview within the dialog is can't be filtered properly. the filter process is fine though, but every time i filtered the Gridview, the Dialog modal will also be closed.
i also have tried to use Pjax by encapsulate the gridview within Pjax widget. this time the modal Dialog won't be closed. but then it can only filter 1 time. once the Gridview is filtered then we can't filter it anymore.
below is my "_form" view : (i am using button called "cari" to trigger the pop up dialog)
<?php $form = ActiveForm::begin(); ?>
<?= $form->field($model, 'judul')->textInput(['maxlength' => true]) ?>
<?= $form->field($model, 'isi')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'kategori_id', [
'addon' => ['append' =>
['content'=>
Html::button('x', ['class'=>'btn btn-default','name' => 'del_kat', 'id' => 'del_kat', 'onclick' => '$("#kat_id").val("");']) . PHP_EOL .
Html::button('Cari', ['class'=>'btn btn-primary','id' => 'modal_kat', 'onclick' => '$("#kategori_dialog").dialog("open"); return false;' ]),
'asButton' => true
]
]
])->textInput(['id'=> 'kat_id', 'readonly' => true]) ?>
here is my GridView Code :
GridView::widget([
'dataProvider' => $kategoriModel->search(Yii::$app->request->queryParams),
'filterModel' => $kategoriModel,
'columns' => [
'kategori_id',
'nama',
[
'label' => 'test',
'format' => 'raw',
'value' => function ($data) {
return Html::button('+', ['class'=>'btn btn-default','id' => 'modal_kat', 'onclick' => '$("#kategori_dialog").dialog("close"); $("#kat_id").val("'.$data->kategori_id.'");' ]);
},
],
],
]);
and here is Dialog Code :
Dialog::begin([
'id' => 'kategori_dialog',
'clientOptions' => [
'modal' => true,
'autoOpen'=>false,
'title'=>'List Kategori',
'width'=>'auto',
],
]);
Pjax::begin(['id' => 'kategori-pjax', 'enablePushState'=>false]);
echo $kategoriGrid;
Pjax::end();
Dialog::end();
as you guys can see, i tried to use Pjax but i couldn't make it work as expected (as i can only filter the Gridview once then it can be filtered again). i remember doing this just fine back in Yii 1.1 (i was using CJuiDialog back).
so i wonder if i am missing something here in Yii 2.0? i am kinda new to Pjax stuff, so i think i miss some properties that have to be set in the Pjax widget.
in my case, the solution to this is by using Kartik's Gridview. i installed it and set the Pjax property to true.
use kartik\grid\GridView;
GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $model,
'columns' => $gridColumns,
'pjax' =>true,
]);
and now i can successfully filter the grid within the dialog. it looks like Kartik has better implementation when wrapping the Grid with Pjax Container.

How to integrate newtinymce + elfinder extension in Yii?

I wanted to integrate elFinder with TinyMCE. More specifically, make it available as a button somewhere on TinyMCE (like inside insert picture dialog).
What I have done so far:
1. have newtinymce, elfinder extensions under protected/extensions folder. (The author said integrating these two would be cleaner in code)
2. have ElfinderController, TinyMceController as described on extension page.
3. inside protected/config/main.php component secion:
'widgetFactory'=>array(
'widgets'=>array(
'TinyMce'=>array(
'language'=>'en',
'settings'=>array(
'language' => 'en',
'theme' => "advanced",
'skin' => 'o2k7',
'plugins' => "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,advlist",
// Theme options
'theme_advanced_buttons1' => "removeformat,pagebreak,visualchars,visualaid,|,insertlayer,moveforward,movebackward,absolute,styleprops,attribs,|,undo,redo,search,replace,cleanup,print,preview,save,newdocument",
'theme_advanced_buttons2' => "pastetext,pasteword,|,hr,blockquote,|,bullist,numlist,outdent,indent,justifyleft,justifycenter,justifyright,justifyfull,ltr,rtl,formatselect",//copy,cut,paste,
'theme_advanced_buttons3' => "nonbreaking,sub,sup,charmap,|,bold,italic,underline,strikethrough,forecolor,backcolor,fontsizeselect,fontselect",
'theme_advanced_buttons4' => "tablecontrols,|,link,unlink,anchor,|,image,media",
'theme_advanced_toolbar_location' => "top",
'theme_advanced_toolbar_align' => "right",
'theme_advanced_statusbar_location' => "bottom",
'theme_advanced_resizing' => true,
'relative_urls' => false,
'spellchecker_languages' => null,
'fileManager'=>array(
'class' => 'ext.elFinder.TinyMceElFinder',
'connectorRoute'=>'elfinder/connector',
),
)
)
)
),
4. in view file:
<?php
$this->widget('ext.tinymce.TinyMce', array(
'model' => $model,
'attribute' => 'content',
'compressorRoute' => 'tinyMce/compressor',
'htmlOptions' => array(
'rows' => 6,
'cols' => 60,
),
)); ?>
This gives me the TinyMCE editor without elFinder window as a button on TinyMCE somewhere (like inside insert picture dialog).
When I add the following inside view file, it gives me an elFinder area directly where I put the code.
<?php $this->widget('ext.elFinder.ServerFileInput', array(
'model' => $model,
'attribute' => 'content',
'connectorRoute' => 'elfinder/connector',
)
);?>
I guess this means elFinder is working. But I don't want it as a separate widget for a field, rather I want it to be part of TinyMCE as stated at the top.
What else do I need to integrate them?
It was a onfiguration problem. fileManager property was not a child of settings, but a sibling.
So config/main.php part should be something like:
'widgetFactory'=>array(
'widgets'=>array(
'TinyMce'=>array(
'language'=>'en',
'settings'=>array(...),
'fileManager'=>array(
'class' => 'ext.elFinder.TinyMceElFinder',
'connectorRoute'=>'elfinder/connector',
),

How to set place holder copy in date select menu in CakePHP

I am using CakePHP 1.3 to create a select menu for date of birth (as below). I can set the default starting values as either blank or a selected date, but ideally I would like to have DD-MM-YYYY as the starting displayed values:
echo $form->input('dob',
array(
'before' => '',
'between' => '',
'after' => '',
'label' => false,
'divider' => false,
'monthNames' => false,
'selected' => false,
'empty' => true,
'dateFormat' => 'DMY',
'minYear' => date('Y') - 70,
'maxYear' => date('Y') - 16,
'error' => array('wrap' => 'div', 'class' => 'error-copy')
));
What I get:
What I would like:
Thank you
I believe if you want to do this you will have to make your own date fields and not use the FormHelper since you can only set a default date to it, what you want involves adding an element to the fields.
You could also try JQuery's datepicker out, it's what I use in my project, and since it's a text field you can just set whatever you want as a placeholder.
http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html#options-for-select-checkbox-and-radio-inputs
echo $this->Form->dateTime('Contact.date', 'DMY', '12',
array(
'empty' => array(
'day' => 'DAY', 'month' => 'MONTH', 'year' => 'YEAR',
'hour' => 'HOUR', 'minute' => 'MINUTE', 'meridian' => false
)
)
);
I believe you can only set a default date on the date fields.
echo $this->Form->input('close_time', array('type' => 'time', 'selected' => '13:30:00'));
Cookbook entry
For the benefit of anyone Googling to find the answer to this question 1+ years after it was asked, we can now simply do the following to set default placeholder (temporary) values in CakePHP forms that are easily replaced when clicked:
<?php echo $this->Form->input('Email', array(
'placeholder'=>'Enter Your Email Here'
)); ?>
I like to include 'label' => false as well to make the forms really minimalist.