You are here

function fieldable_panels_panes_services_update in Fieldable Panels Panes (FPP) 7

Updates a Fieldable Panels Pane.

Parameters

int $fpid: The Fieldable Panels Pane ID.

array $fpp: Fieldable Panels Pane.

Return value

int|mixed Unique identifier for the Fieldable Panels Pane or FALSE if there was a problem.

1 string reference to 'fieldable_panels_panes_services_update'
fieldable_panels_panes_services_resources in ./fieldable_panels_panes.services.inc
Implements hook_services_resources().

File

./fieldable_panels_panes.services.inc, line 273
Contains callbacks for service resource manipulation.

Code

function fieldable_panels_panes_services_update($fpid, array $fpp) {
  $fpp['pfid'] = $fpid;
  $old_fpp = fieldable_panels_panes_load($fpid);
  if (empty($old_fpp)) {
    return services_error(t('Fieldable Panels Pane @fpid not found.', array(
      '@fpid' => $fpid,
    )), 404);
  }

  // Setup form_state.
  $form_state = array();
  $form_state['values'] = $fpp;
  $form_state['entity'] = $old_fpp;
  drupal_form_submit('fieldable_panels_panes_entity_edit_form', $form_state);
  if ($errors = form_get_errors()) {
    return services_error(implode(" ", $errors), 406, array(
      'form_errors' => $errors,
    ));
  }
  return $fpid;
}