You are here

function theme_jeditable_formatter_jeditable_checkbox_radio in jEditable inline content editing 7

Theme a boolean_list field as a jeditable checkbox or radio button.

File

./jeditable.module, line 345
jeditable.module TODO: Provides integration between Drupal and the jEditable jquery plugin @todo: Datepicker support @todo: Ajax upload support @todo: Radioboxes/checkboxes support @todo: add required handler for date @todo: add compatibility for…

Code

function theme_jeditable_formatter_jeditable_checkbox_radio($variables) {
  $element = $variables['element'];
  $field = $variables['field'];
  $entity = $variables['entity'];
  $entity_type = $variables['entity_type'];
  $delta = $variables['delta'];
  $widget_type = $variables['widget_type'];
  switch ($entity_type) {
    case 'node':

      // Check user's access to editing this node.
      if (!node_access('update', $entity)) {
        return $element['value'];
      }
      $id = $entity->nid;
      break;
    case 'user':

      // Check user's access to editing this user.
      if (!user_edit_access($entity)) {
        return $element['value'];
      }
      $id = $entity->uid;
      break;
  }
  if ($entity_type == 'node') {
    $entity_type = 'field';
  }

  // add check on checkbox or radio

  /**
   * needs custom ...
   * limit  = 1     -> radio
   * limit >= 1     -> checkbox
   * also see ajaxcall class.. adjust
   */
  return '<span id="' . $entity_type . '-' . $id . '-' . $field['field_name'] . '-' . $widget_type . '-' . $variables['delta'] . '" class="jeditable jeditable-' . $widget_type . '">' . $element['value'] . '</span>';
}