Top menu

Define a default value in configureFormFields

To add some some default field value whith SonataAdminBundle you should use the getNewInstance function :

 

0

How to use a callback with SonataAdminBundle sonata_type_model_autocomplete in configureFormFields

The callback in sonata_type_model_autocomplete configuration is a callable function that can be used to modify the query which is used to retrieve autocomplete items. The callback should receive three parameters – the Admin instance, the property (or properties) defined as searchable and the search value entered by the user.

 

0

Add join with custom database table in hook_views_query_alter()

In this example i would add a join to the database table “node” with an other database table “event_submissions” which i created in my custom module, so i will add a hook_views_query_alter() function in mymodule.module file :

This code allows me to get the events that the current user had participated.

0

Create a class to consume soap web service

There is an example of class to show you how to write code to consume a SOAP based web service.

In the code below a demo of how to instanciate this class and call the RequestSW method :

 

0

Alter captcha field with the hook_element_info_alter()

If you want to change the field properties of  the Captcha module or the Image CAPTCHA module you will see that this is not possible with hook_form_alter () because through this function we can not access to the fields of the captcha, the picture below shows an example of what you get when we display the variable $form in […]

0

Sql script to execute after moving a WordPress Website to New Domain or Location

   

 

0

Advanced example of using the “for” and “loop” in twig

This example illustrate how to use a nested “for” in twig also the use of a loop instruction:

Inside of a for loop block you can access some special variables: Variable Description loop.index The current iteration of the loop. (1 indexed) loop.index0 The current iteration of the loop. (0 indexed) loop.revindex The number of iterations from […]

0

Coding Standards for Drupal, Symfony and Twig

Twig : http://twig.sensiolabs.org/doc/coding_standards.html Symfony : http://symfony.com/doc/current/contributing/code/standards.html Drupal : https://drupal.org/coding-standards Configuring drupal with netbeans : https://drupal.org/node/1019816

0

How to use the Intl Extension Twig for date

First you should install the php5-intl :

Then add the code below in your “app/config/config.yml” file :

Finaly in you twig file you can use the localizeddate filter to format dates into a localized string representating the date :

 

0

How to truncate String by Words

If you simply want to truncate text to a certain number of words, because you do not want a word will be cut, the code below will do the trick:

 

0