December 02 2015

Yii2 cactiveform client validation not working with fancybox ajax

Tagged Under :

If using fancybox ajax display the Yii2 cactiveform you will found that the client validation are not working.

Its due to the form ID was invalid or duplicated in same page. what you need to do is assign a new form id inside cactiveform.

$form = ActiveForm::begin([
  'enableClientValidation' => true,
  'id' => 'new_form_id'

December 02 2015

Yii2 gridview column pass an array as param

Tagged Under :

In Yii2 now you are allow pass an array as param to gridview column for display the data. Below is the example how to pass array to gridview column.

The $status is an array and $data is the model results.
'content' => function($data) use ($status) {
  return (isset($status[$data->status]) ? $status[$data->status] : $data->status);

Complete Example:
  'filterModel' => $model,
  'columns' => [
      'attribute' => 'status',
      'filter' => $status,
      'content' => function($data) use ($status) {
        return (isset($status[$data->status]) ? $status[$data->status] : $data->status);
]); ?>

October 22 2015

CSS set opacity background color only not text and image

Tagged Under :

To set the opacity level for a <div> element as the below example:
div {
    opacity: 0.5;
But the following example will let the content inside the <div> become transparent as well.

Instead of using “opacity” to set transparent background-color. You can try using “rgba” function as below.
background-color: rgba(255, 0, 0, 0.5);
Now, only the background is transparent.

October 17 2015

CSS removing dotted outline when click link

Tagged Under :

A links <a> by default have a dotted outline around them when user click it, and it will be a gray color around on it.This is default styling for the purpose of accessibility. For folks without the ability to use a mouse, they still need some visual indicator that they currently have a link active.
To remove the dotted outline, just include this as a part of your CSS
a:link, a:hover, a:active, a:focus {
  outline: 0;

August 31 2015

Android SDK click twice back button to exit

Tagged Under :

A lot of Android users have experience accidentally exit the application when he click the back button.

To avoid this happen again. you can modify back button action to let user click twice before exit.
press again to exit

And also, you can display message “Press again to exit” to ask the user click again to exit the application.

July 29 2015

Mysql query to display name range from a to g

Tagged Under :

I need to listing out name of the person start from lowercase a to g and uppercase A to G in MySQL. You can use MySQL regexp to get the results you want.

Example SQL:

The above query will listing out all the results where name start from a to g

June 28 2015

PHP some variable fail to post data to server

Tagged Under :

This was my first time facing this problem. When I post more than 1000 variable value to server, it only show me 1000 variable received and the rest was missing.

To solve this problem you need to increase max_input_vars number in PHP.ini to 3000 or 5000. It was because the max_input_vars default value was 1000. If you post more than the value server will ignore the rest.

if your server uses the Suhosin patch or after change the max_input_vars number the problem still same. you can try add = 3000 
suhosin.request.max_vars = 3000
to increase the maximum number of post variable.

June 08 2015

IOS css radius courners and glare on inputs

Tagged Under :

Inside the iOS devices have add some annoying styles on form input, particularly on input box and submit button. Below are the simple form on Desktop and iOS browser.



To fixed the border radius and gradient on IOS safari browser issue.
You can get rid of the webkits form, input, etc. styling with this:
input, textarea, select {
   -webkit-appearance: none;

May 19 2015

css div 100% height

Tagged Under :

A lot of people are trying to set div to 100% inside the CSS to fill up the full height of browser window. But normally it wouldn’t work.

In here, I will showing you how to set 100% full height div with CSS. Inside the CSS class remember set html and body element to height 100%.
html, body {
  height: 100%;
After that, set the div CSS class to height 100% which you want it full height.
div.content {
  height: 100%;
And the HTML code will look like this
    <div class="content">
      100% full height

Click here to see the DEMO.

April 14 2015

Paypal rest API add discount on the total amount

Tagged Under :

On Paypal rest APi, it don’t have a specifies discount function for the payment. And you are not allow minus the discount price from the total amount, because Paypal itself will add all the items total price when you submit. If the total price are different with the amount you set. It will return an error for you.

The simple way to set the discount price in Paypal APi. you can set the discount as an item. For example to set the discount.
$item3 = new Item();
$item3->setName('Voucher Discount')
    ->setDescription('Voucher Discount')
Remember you must set the price as ‘-10’ no -10. If the latter´╝î it will become 0 and then the total items prices will different with the Total amount you set inside the Transaction. Once it different Paypal will return an error for you.