Add default blank value for select option in contact form 7 wordpress

Normally when you use contact form 7 plugin , for dropdown select option, there is no option to set blank value for the first option to validate the select field.

For example, what we have in wordpress contact form 7

<select name=”your_field_name”>
<option value=””>—</option>
<option value=”yes”>Yes</option>
<option value=”no”>No</option>

But in actual scenario, i want to display the label for the first option as “–Select Value–” with empty value.
To make the same change, you can use the dropdown code as below
[select* your_field_name_ class:form-select class:required first_as_label “–Select Value–” “Yes” “No”]

In the above code “first_as_label” is important parameter. It instruct the plugin to use the first option as label with default empty value. So the generated output look as below

<select name=”your_field_name”>
<option value=””>–Select Value–</option>
<option value=”yes”>Yes</option>
<option value=”no”>No</option>

If you have any queries, you can write back to us or comment in the comment section.

Yii2 how to set custom value for checkbox in gridview widget

In Yii2, while you use gridview widget to display your table data, for performing any operation on the record by selecting the checkbox, gridview assign the value of the first column retrieved from your the result set.

But you need to set some different value to the checkbox, so to do that you can use the below code

	'dataProvider' => $dataProvider,
	'filterModel' => $searchModel,
	'columns' => [
		['class' => 'yii\grid\SerialColumn'],
			'class' => '\kartik\grid\CheckboxColumn',
			'checkboxOptions' => function($model, $key, $index, $widget) {
				return ["value" => $model['id']]; // this can be substituted with any column value of your result data
		['class' => 'yii\grid\ActionColumn'],

instead of the default one

	'dataProvider' => $dataProvider,
	'filterModel' => $searchModel,
	'columns' => [
		['class' => 'yii\grid\SerialColumn'],
			'class' => '\kartik\grid\CheckboxColumn',
		['class' => 'yii\grid\ActionColumn'],

How to search in specific content type in drupal 7

Suppose you have created a content type named as “testimonial”. Now the requirement is to for search for a value “hello” under field name “title” then you can do so by using the below query. Please make sure that you have the “Entity API”  module enabled.


$searchkeyword = $_REQUEST['keyword'];
$query = new EntityFieldQuery();
$result = $query->entityCondition('entity_type', 'node')
->entityCondition('bundle', '[The machine name for your content type]') // in our case it is "testimonial"
->propertyCondition('title', $searchkeyword)
->propertyCondition('status', 1)
->fieldCondition('field_active_status', 'value', 'active',"=") // here you have to define your where condition on additional fields if required

Validate checkbox array and prefill with selected value on validation error in laravel 5

Say for example you have your checkbox field code in your twig file as below:-

@foreach ($serviceList as $servloop)
<div class=”checkbox”>
<input type=”checkbox” name=”services[]” value=”{{$servloop->service_id}}” {{ ( is_array(old(‘services’)) && in_array($servloop->service_id, old(‘services’)) ) ? ‘checked ‘ : ” }} />

Controller file code

Validation Rule will be as below:-

$rules = [
‘services’ => ‘required|min:1’,  // min:1 means atleast one should be selected

$customMessages = [
‘services.required’ => ‘Select the service you will need from us, for and during the Expo.’,




How to wrap data column in Gridview widget in yii or yii2 framework

The column which you want to wrap should be added the property called “contentOptions” where you can apply the css property to suits your needs and requirements as below.

‘attribute’ => ‘column name’,
‘format’ => ‘html’,
‘noWrap’ => false,
‘contentOptions’ => [‘style’ => ‘width: 50%; overflow: scroll;word-wrap: break-word;white-space:pre-line;’],
‘value’=>function ($data) {
return $data[‘question’];

Set widget label from action file in symfony 1.4

In Action File


$this->form = new youFormclassname();

To set individual Label

$this->form->getWidget(‘widgetname’)->setLabel(‘widget Custom label’);

To set multiple field label

‘field_name_1’    => ‘Field 1 Custom Lable’,

‘field_name_2’    => ‘Field 2 Custom Lable’,



In Template File


<?php echo $form[‘field_name_1’]->renderLabel() ?>

Create template specific to node in drupal 6

If you want to have custom templates for your node. You can create templates specific to node ID as follows.

Add the below function in your template.php if its not exists.

function yourcurrentthemename_preprocess_node(&$vars, $hook) {
$node = $vars[‘node’];
$vars[‘template_file’] = ‘node-‘. $node->nid;

If the function already exists then add the two lines at the beginning of the function.

Then clear the cache.

So if you want to have a custom template for node id 3 (say for example) then create a template with name node-3.tpl.php in your theme directory.

Now you can customise your template as you need.

Keep Rocking…..Enjoy 🙂

How to get the allowed option list in drupal theme template or view file

If you want to get the option list of the content type that you have created , then you can get the list as follows:

$content_field = content_fields(‘whatever_the_field_name_is’);
$allowed_values = content_allowed_values($content_field);

So the $allowed_values will give you the array of the option list with the key value association.

Note: The “whatever_the_field_name_is” is the field name that you had specified while adding the field, you can get the field name from your content type .

How to add select option in drupal while creating content type

Whenever you create any content type in drupal ( version 6 and above) and you required a filed of type select list, then you can provide the allowed values of the select option in two ways

CASE 1 :

option 1
option 2
option 3

CASE 2 :

1|option 1
2|option 2
3|option 3

Each new option has to be entered on a new line
So enternally the select list generated would be as follows
In case 1 :

<option value=”option 1″>option 1</option>
<option value=”option 2″>option 2</option>
<option value=”option 3″>option 3</option>

In case 2 :

<option value=”1″>option 1</option>
<option value=”2″>option 2</option>
<option value=”3″>option 3</option>