You are here

function webform_component_update in Webform 7.4

Same name and namespace in other branches
  1. 5.2 webform_components.inc \webform_component_update()
  2. 6.3 includes/webform.components.inc \webform_component_update()
  3. 6.2 webform_components.inc \webform_component_update()
  4. 7.3 includes/webform.components.inc \webform_component_update()

Update an existing component with new values.

Parameters

$component: A full component containing a nid, cid, and all other fields from the component form. Additional properties are stored in the extra array.

2 calls to webform_component_update()
webform_component_edit_form_submit in includes/webform.components.inc
Submit handler for webform_component_edit_form().
webform_node_update in ./webform.module
Implements hook_node_update().

File

includes/webform.components.inc, line 829
Webform module component handling.

Code

function webform_component_update($component) {

  // Allow modules to modify the component before saving.
  foreach (module_implements('webform_component_presave') as $module) {
    $function = $module . '_webform_component_presave';
    $function($component);
  }
  $component['value'] = isset($component['value']) ? $component['value'] : NULL;
  $component['required'] = isset($component['required']) ? $component['required'] : 0;
  $component['extra']['private'] = isset($component['extra']['private']) ? $component['extra']['private'] : 0;
  db_update('webform_component')
    ->fields(array(
    'pid' => $component['pid'],
    'form_key' => $component['form_key'],
    'name' => $component['name'],
    'type' => $component['type'],
    'value' => isset($component['value']) ? $component['value'] : '',
    'extra' => serialize($component['extra']),
    'required' => $component['required'],
    'weight' => $component['weight'],
  ))
    ->condition('nid', $component['nid'])
    ->condition('cid', $component['cid'])
    ->execute();

  // Post-update actions.
  module_invoke_all('webform_component_update', $component);
}