You are here

function editableviews_handler_field_node_title_edit::edit_form in Editable Views 7

Return the edit form for the field.

File

handlers/editableviews_handler_field_node_title_edit.inc, line 46

Class

editableviews_handler_field_node_title_edit
Field handler for node title editable field.

Code

function edit_form($entity_type, $entity, &$element, &$form_state) {

  // Just do the same thing as node_content_form().
  $type = node_type_get_type($entity);
  $element['title'] = array(
    '#type' => 'textfield',
    '#title' => check_plain($type->title_label),
    // This is required on existing entities, but not on new ones to allow
    // the user to not create the new entity.
    // Obviously, problems arise when there are multiple editable fields on
    // this entity, since the title *is* required if actually creating an
    // entity!
    // TODO: consider this thorny problem.
    '#required' => isset($entity->nid),
    // The title might not be set in the case where we're on a non-required
    // relationship with empty data.
    '#default_value' => isset($entity->title) ? $entity->title : '',
    '#size' => $this->options['textfield_size'],
    '#maxlength' => 255,
  );
}