Get list options of a field
Submitted by system on Wed, 07/16/2014 - 11:14We may want to get the options available for a field in content type. This can be achieved using Field API.
We may want to get the options available for a field in content type. This can be achieved using Field API.
"In software engineering, a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. A design pattern is not a finished design that can be transformed directly into source or machine code."
As an effort towards learning and documenting key findings, I will be sharing the design concepts as I move on:
Strategy Pattern: Define a family of algorithms, encapsulate each one, and make them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
This post will illustrate various handy file operations available in Drupal
Get Absolute Path of a file from URI : drupal_realpath()
A URI in drupal looks like: private://donor_registration/somefile.csv for a private file
Absolute Path: /srv/www/example.com/public_html/sites/default/private/files/donor_registration/somefile.csv
There are times when we would want to create similar data structures across multiple drupal sites for common functionalities. Although this can be done using features but when the effort involves one time exercise and involves just few fields to be exported, using custom code for creating export definitions for importing in the other site can be a simpler alternative.
If you want export a field definition, you can use the handy field_info_field and field_info_instance functions. Taking our example above, here's how you would call these two functions:
Drupals internal batch API can be really helpful for handling large cumbersome processes on your web server. Rather than submitting a form and waiting for one of these processes to finish before reaching the next page, the batch API can be utilized to break the process down across multiple page loads. This not only cuts down on the server load, but will prevent the page from timing out. Progress bars will be displayed to the user while the process runs which will keep them informed of where they are at in the process.
The purpose is to modify the integer field which captures temperature in decimal.
A good way is to execute a hook_update_N() API in custom module which allows incremental updates when installing, or visiting update.php
WARNING: Does not work. Its better to recreate field after copying data to another temp field.
[ http://drupal.stackexchange.com/questions/103157/modifying-integer-field... ]
Quicktabs by default strips html tags in Quicktab title by default. To add additional markup of text changes, hook_quicktabs_alter() is not sufficient the quicktabs tabset needs to be overriden to allow html markup in titles.
hook_quicktabs_alter() to modify title. In the example modification for the first tab is done
Requirement: Modify the file description field to change the label and help text for a specific content type. This feature is provided by file field and a simple form_alter was not useful to modify the description label of the file field.
Display a group fieldset using form state api.
The task was to change text field to a select list with a given set of option. The text field was an integer field and the select options were numbers to select from 0 to 30.