public function FlexiformElementNodeTitle::form in Flexiform 7
Return the form element for this FlexiformElement.
Overrides FlexiformElement::form
File
- includes/
element/ node_title.element.inc, line 15 - Contains class for the Node title element.
Class
- FlexiformElementNodeTitle
- 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;
}