Commit 985884f9 authored by webchick's avatar webchick
Browse files

#559506 by quicksketch and plach: Added variable to field widgets.

parent 2a2a7f3f
......@@ -620,6 +620,8 @@ function hook_field_widget_info_alter(&$info) {
* The field structure.
* @param $instance
* The field instance.
* @param $langcode
* The language associated to $items.
* @param $items
* Array of default values for this field.
* @param $delta
......@@ -627,7 +629,7 @@ function hook_field_widget_info_alter(&$info) {
* @return
* The form item for a single element for this field.
*/
function hook_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
function hook_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
$element = array(
'#type' => $instance['widget']['type'],
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
......
......@@ -57,7 +57,7 @@ function field_default_form($obj_type, $object, $field, $instance, $langcode, $i
$delta = isset($get_delta) ? $get_delta : 0;
$function = $instance['widget']['module'] . '_field_widget';
if (function_exists($function)) {
if ($element = $function($form, $form_state, $field, $instance, $items, $delta)) {
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
$defaults = array(
'#required' => $get_delta > 0 ? FALSE : $instance['required'],
'#columns' => array_keys($field['columns']),
......@@ -157,7 +157,7 @@ function field_multiple_value_form($field, $instance, $langcode, $items, &$form,
$function = $instance['widget']['module'] . '_field_widget';
if (function_exists($function)) {
for ($delta = 0; $delta <= $max; $delta++) {
if ($element = $function($form, $form_state, $field, $instance, $items, $delta)) {
if ($element = $function($form, $form_state, $field, $instance, $langcode, $items, $delta)) {
$multiple = $field['cardinality'] > 1 || $field['cardinality'] == FIELD_CARDINALITY_UNLIMITED;
$defaults = array(
// For multiple fields, title and description are handled by the wrapping table.
......
......@@ -330,13 +330,15 @@ function number_elements() {
* The field structure.
* @param $instance
* the field instance array
* @param $langcode
* The language associated to $items.
* @param $delta
* the order of this item in the array of subelements (0, 1, 2, etc)
*
* @return
* the form item for a single element for this field
*/
function number_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
function number_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
$element = array(
'#type' => $instance['widget']['type'],
'#default_value' => isset($items[$delta]) ? $items[$delta] : NULL,
......
......@@ -98,7 +98,7 @@ function options_elements() {
/**
* Implement hook_field_widget().
*/
function options_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = NULL) {
function options_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
$element = array(
'#type' => $instance['widget']['type'],
'#default_value' => !empty($items) ? $items : array(),
......
......@@ -594,6 +594,8 @@ function text_elements() {
* The field structure.
* @param $instance
* the field instance array
* @param $langcode
* The language associated to $items.
* @param $items
* array of default values for this field
* @param $delta
......@@ -602,7 +604,7 @@ function text_elements() {
* @return
* the form item for a single element for this field
*/
function text_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
function text_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
$element = array(
'#type' => $instance['widget']['type'],
'#default_value' => isset($items[$delta]) ? $items[$delta] : '',
......
......@@ -495,7 +495,7 @@ function field_test_field_widget_info() {
* @return
* the form item for a single element for this field
*/
function field_test_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = 0) {
function field_test_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = 0) {
$element = array(
'value' => array(
'#title' => $instance['label'],
......
......@@ -2017,7 +2017,7 @@ function taxonomy_term_title($term) {
/**
* Implement hook_field_widget().
*/
function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $items, $delta = NULL) {
function taxonomy_field_widget(&$form, &$form_state, $field, $instance, $langcode, $items, $delta = NULL) {
$element = array(
'#type' => $instance['widget']['type'],
'#default_value' => !empty($items) ? $items : array(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment