From f977c064a736fb6334dbe4724454caf5f7c9d83d Mon Sep 17 00:00:00 2001
From: Mariano D'Agostino <dagmar@154086.no-reply.drupal.org>
Date: Sat, 13 Apr 2013 10:31:42 -0300
Subject: [PATCH] Issue #1969548 by dagmar: Provide an alternative to title in
 behaviour, just a basic input property.

---
 plugins/property_behavior/basic_input.inc |   44 +++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 plugins/property_behavior/basic_input.inc

diff --git a/plugins/property_behavior/basic_input.inc b/plugins/property_behavior/basic_input.inc
new file mode 100644
index 0000000..e68ce9b
--- /dev/null
+++ b/plugins/property_behavior/basic_input.inc
@@ -0,0 +1,44 @@
+<?php
+/*
+ * Implementation of basic_input property behavior, which includes a non-required
+ * field in the entity form.
+ */
+$plugin = array(
+  'label' => "Basic input",
+  'default_widget' => 'eck_basic_input_property_widget',
+  'default_formatter' => 'eck_basic_input_property_formatter'
+);
+
+/**
+ * Define a rendarble array to input a value for the property using this behavior
+ *
+ * @param $entity: and entity object that contains the property for which this behavior is relevant
+ * @param $property: the name of the property (string) that is using this behavior
+ *
+ * @return a rendarable array use when the input form for this entity is displayed
+ */
+function eck_basic_input_property_widget($property, $vars){
+  $entity = $vars['entity'];
+  $value = _eck_basic_input_property_extract_basic_input($entity, $property);
+  return array(
+    '#type' => 'textfield',
+    '#title' => $vars['properties'][$property]['label'],
+    '#default_value' => $value,
+  );
+}
+
+function eck_basic_input_property_formatter($property, $vars){
+  $entity = $vars['entity'];
+  $value = _eck_basic_input_property_extract_basic_input($entity, $property);
+  return array('#markup' => check_plain($value));
+}
+
+function _eck_basic_input_property_extract_basic_input($entity, $property){
+  $value = "";
+  if(isset($entity->{$property})){
+    $value = $entity->{$property};
+  }
+
+  return $value;
+}
+
-- 
1.7.9.5

