From 7214a3db953f7da96c8487bcf5fae45a720756bd Mon Sep 17 00:00:00 2001
From: Lucas D Hedding <lucashedding@1463982.no-reply.drupal.org>
Date: Thu, 25 Jul 2013 08:38:12 -0500
Subject: [PATCH] Issue #2045847 by heddn: Added ability to flag parameters as
 optional.

---
 wsclient_ui/wsclient_ui.inc |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/wsclient_ui/wsclient_ui.inc b/wsclient_ui/wsclient_ui.inc
index 0df37be..7d437c5 100644
--- a/wsclient_ui/wsclient_ui.inc
+++ b/wsclient_ui/wsclient_ui.inc
@@ -759,7 +759,7 @@ function wsclient_ui_type($form, &$form_state, $service, $type, $op = 'edit') {
     '#element_validate' => array('wsclient_ui_validate_parameters'),
     '#theme' => 'wsclient_ui_property_form',
     '#title' => t('Properties'),
-    '#description' => t('Specify the properties for the data type. For each property you have to specify a certain data type and a unique name containing only alphanumeric characters and underscores.'),
+    '#description' => t('Specify the properties for the data type. For each property you have to specify a certain data type and a unique name containing only alphanumeric characters and underscores. You can also specify if null values are allowed.'),
   );
   $types = wsclient_ui_types();
   if (isset($type['property info'])) {
@@ -811,6 +811,7 @@ function wsclient_ui_type_submit($form, &$form_state) {
       $type['property info'][$item['name']] = array(
         'type' => $unmapped_type,
         'label' => $item['label'],
+        'allow null' => $item['allow_null'],
       );
       if ($item['multiple']) {
         $type['property info'][$item['name']] = array('type' => 'list<' . $unmapped_type . '>');
@@ -911,6 +912,10 @@ function _wsclient_ui_property_row($service, $types, $name = '', $info = array()
     '#size' => 40,
     '#default_value' => isset($info['label']) ? $info['label'] : '',
   );
+  $property['allow_null'] = array(
+    '#type' => 'checkbox',
+    '#default_value' => isset($info['allow null']) ? $info['allow null'] : FALSE,
+  );
   return $property;
 }
 
@@ -923,7 +928,7 @@ function theme_wsclient_ui_property_form($variables) {
   $elements = $variables['element'];
 
   $table['#theme'] = 'table';
-  $table['#header'] = array(t('Data type'), t('Multiple'), t('Name'), t('Label'));
+  $table['#header'] = array(t('Data type'), t('Multiple'), t('Name'), t('Label'), t('Allow Null'));
   $table['#attributes']['id'] = 'rules-' . drupal_html_id($elements['#title']) . '-id';
 
   foreach (element_children($elements['items']) as $key) {
@@ -934,6 +939,7 @@ function theme_wsclient_ui_property_form($variables) {
     $row[] = array('data' => $element['multiple']);
     $row[] = array('data' => $element['name']);
     $row[] = array('data' => $element['label']);
+    $row[] = array('data' => $element['allow_null']);
     $row = array('data' => $row) + $element['#attributes'];
     $table['#rows'][] = $row;
   }
-- 
1.7.10.4

