You are here

public function PartyActivityElementTitle::form in Party 7

Return the form element for this FlexiformElement.

Overrides FlexiformElement::form

File

modules/party_activity/includes/element/party_activity_title.element.inc, line 15
Contains class for the Node title element.

Class

PartyActivityElementTitle
Class to add the node title field to a form.

Code

public function form($form, &$form_state, $entity, $language = LANGUAGE_NONE) {
  $parents = $form['#parents'];
  $parents[] = 'title';

  // Work out the default value.
  $default = '';
  if (!empty($this->settings['default_value']['default_value'])) {
    $default = $this->settings['default_value']['default_value'];
  }
  if (!empty($this->settings['default_value']['use_tokens'])) {
    $default = $this
      ->replaceCtoolsSubstitutions($default, $form['#flexiform_entities']);
  }
  $form[$this->element_namespace] = array(
    '#type' => 'textfield',
    '#parents' => $parents,
    '#title' => $this
      ->label(),
    '#required' => TRUE,
    '#default_value' => !empty($entity->title) ? $entity->title : $default,
    '#maxlength' => 255,
  );
  $form = parent::form($form, $form_state, $entity);
  return $form;
}