I have a print layout in haml for generating pdfs:
= link_to I18n.t('eda.print'), {:controller => :persons, :action => :print}, :method => '', :remote => false
Is there a way to have a javascript popup for confirmation like "are you sure?" just before executing the print method?
Non-javascript way:
= link_to I18n.t('eda.print'), {:controller => :persons, :action => :print},
:method => '', :remote => false, :data => {:confirm => 'Are you Sure ?' }
On clicking the link, it'll ask for user confirmation 'Are you Sure?' If you proceed further then respective controller -> action will be triggered.
Related
I want to add one button in Nav bar for redirect to index.php. Please Help me to complete the task.i want to redirect to this below url
http://localhost/Backup/web/index.php
i trying the below code,
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'encodeLabels' => false,
'items' => [
['label' => 'ContactUs', 'url' => ['index.php']],
],
]);
Try this
'url'=> Yii::$app->homeUrl
Try this :
echo Nav::widget([
'options' => ['class' => 'navbar-nav navbar-right'],
'encodeLabels' => false,
'items' => [
['label' => 'ContactUs', 'url' => ['web/index']],
],
]);
I made a button in my site and it executes a script in my CentOS, but I'm looking for a solution to put a confirmation box to execute the action.
The button:
$attribs[] = array(
'label' => Yii::t('mc', 'Instalar Technic -> B Team'),
'type' => 'raw',
'cssClass' => 'mpack',
'value' => CHtml::ajaxButton(
Yii::t('mc', 'Instalar B Team'),
'',
array(
'type' => 'POST',
'data' => array(
'ajax' => 'bteam',
Yii::app()->request->csrfTokenName=>Yii::app()->request->csrfToken,),
'success' => 'function(e) {
if (e) alert(e);
}'
),
array('class' => 'btn btn-success btn-sm')),
'hint' => Yii::t('mc', 'Servidor não liga? Este botão seta "true" na "eula.txt", é necessario isso para seu servidor ligar, cheque seu console para verificação.'),
//Edit the hint option here
);
You can add a confirmation box simply declaring the proper data-confimr in your link
'value' => CHtml::ajaxButton(
Yii::t('mc', 'Instalar B Team'),
'',
array(
'type' => 'POST',
'data' => array(
'ajax' => 'bteam',
Yii::app()->request->csrfTokenName=>Yii::app()->request->csrfToken,),
'success' => 'function(e) {
if (e) alert(e);
}'
),
array('class' => 'btn btn-success btn-sm',
'confirm' => "do you want confirm this action ?" ),
));
I am working on leave management system plugin so want to show application menu under lms menu.... here i past my init file code
menu :top_menu, :leave_transactions, { :controller => 'dashboard', :action => 'index' }, :caption => 'LMS' , :if => Proc.new { User.current.logged? }
menu :application_menu, :dashboard, { :controller => 'dashboard', :action => 'index' }, :caption => 'Dashboard' , :if => Proc.new { User.current.logged? }
menu :application_menu, :leave_transactions, { :controller => 'leave_transactions', :action => 'index' }, :caption => 'Apply Leave' , :if => Proc.new { User.current.logged? }
menu :application_menu, :holiday_informations, { :controller => 'holiday_informations', :action => 'index' }, :caption => 'Holiday' , :if => Proc.new { User.current.logged? }
Its working for me but application menu display all over menu. so i want to avoid this and when I click on lms menu that time application menu display..please help me
Hi I'm using the test code from http://www.yiiframework.com/doc/api/1.1/CMenu
$this->widget('zii.widgets.CMenu', array(
'items'=>array(
// Important: you need to specify url as 'controller/action',
// not just as 'controller' even if default acion is used.
array('label'=>'Home', 'url'=>array('site/index')),
// 'Products' menu item will be selected no matter which tag parameter value is since it's not specified.
array('label'=>'Products', 'url'=>array('product/index'), 'items'=>array(
array('label'=>'New Arrivals', 'url'=>array('product/new', 'tag'=>'new')),
array('label'=>'Most Popular', 'url'=>array('product/index', 'tag'=>'popular')),
)),
array('label'=>'Login', 'url'=>array('site/login'), 'visible'=>Yii::app()->user->isGuest),
),
));
Other test code such as zii.widgets.jui.CJuiAutoComplete and zii.widgets.jui.CJuiDraggable work fine in my Yii view...
The CMenu code snippet just shows the links as a hierarchical list.
When using a div with an id of mainmenu things seem to improve a bit... then I tried using a lot of nested arrays:
http://sky-walker.net/temp/test/yii/testnews/index.php?r=site/test
It supports array nesting of 5+ levels deep...
But if I highlight/select it all (to display the white menu links) it doesn't display the hierarchy nicely...
I was wondering if it could be a popup menu that gradually shows children if the parents are hovered over?
I also tried disabling the div with id of mainmenu from the layout's main.php.
ok, after seeing what you have, follow my example:
<div id="mainmenu">
<?php
$this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => 'linkbook', 'url' => array('/site/index')),
array('label' => 'About', 'url' => array('/site/page', 'view' => 'about')),
array('label' => 'Contact', 'url' => array('/site/contact')),
array('label' => 'Suggest Website', 'url' => array('/websiteSuggest/index'),'visible' => !Yii::app()->user->isGuest),
array('label' => 'Servers', 'url' => array('/server/index'),'visible' => !Yii::app()->user->isGuest),
array('url' => Yii::app()->getModule('user')->loginUrl, 'label' => Yii::app()->getModule('user')->t("Login"), 'visible' => Yii::app()->user->isGuest),
array('url' => Yii::app()->getModule('user')->registrationUrl, 'label' => Yii::app()->getModule('user')->t("Register"), 'visible' => Yii::app()->user->isGuest),
array('url' => Yii::app()->getModule('user')->profileUrl, 'label' => Yii::app()->getModule('user')->t("Profile"), 'visible' => !Yii::app()->user->isGuest),
array('url' => Yii::app()->getModule('user')->logoutUrl, 'label' => Yii::app()->getModule('user')->t("Logout") . ' (' . Yii::app()->user->name . ')', 'visible' => !Yii::app()->user->isGuest),
),
));
?>
</div><!-- mainmenu -->
<br/>
<div id="mainmenu">
<?php
$this->widget('zii.widgets.CMenu', array(
'items' => array(
array('label' => 'Website', 'url' => array('/website/index'), 'visible' => !Yii::app()->user->isGuest),
array('label' => 'Url', 'url' => array('/url/index'), 'visible' => !Yii::app()->user->isGuest),
array('label' => 'Pattern Url', 'url' => array('/patternUrl/index'), 'visible' => !Yii::app()->user->isGuest),
),
));
?>
</div>
I'm using the MbMenu Yii extension now...
http://www.yiiframework.com/extension/mbmenu
It is very easy to install and use and it seems the input array from CMenu can be reused with it (as well as the CssMenu Yii extension)...
It is at the bottom of:
http://sky-walker.net/temp/test/yii/testnews/index.php?r=site/test
I'm a bit confused.
This is the form_for in the Getting Started section of Paperclip's Github repository:
<%= form_for #user, :url => users_path, :html => { :multipart => true } do |form| %>
This is the form_for that is generated with Devise:
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
How should I modify it to get Paperclip working?
Just add :multipart => true to the :html parameter like so.
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put, :multipart => true }) do |f| %>