]> gitweb.fluxo.info Git - drupal/reminder.git/commitdiff
Adding description field
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 3 Sep 2012 15:57:14 +0000 (12:57 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 3 Sep 2012 15:57:14 +0000 (12:57 -0300)
reminder.install
reminder.module

index a5bbbb0821e3b0968d484c7042039b972a1adbbe..395838ae8ebd718af4f8383ee61cfbeea3254170 100644 (file)
@@ -64,6 +64,11 @@ function reminder_schema() {
         'not null' => TRUE,
         'default' => '0'
       ),
+      'description' => array(
+          'description' => t('Reminder description'),
+          'type'        => 'text',
+          'length'      => 5000,
+       ),
     ),
     'primary key' => array('nid'),
   );
@@ -189,3 +194,16 @@ function reminder_update_7001(&$sandbox) {
     )
   );
 }
+
+/**
+ * Adds description field.
+ */
+function reminder_update_7002(&$sandbox) {
+  db_add_field('reminder', 'description',
+    array(
+      'description' => t('Reminder description'),
+      'type'        => 'text',
+      'length'      => 5000,
+    )
+  );
+}
index cea6cd4e1134fdfec87853294bcc4d9732e435d2..d96743b0f7c32cd5b5444dd26948d8d279beed2a 100644 (file)
@@ -147,14 +147,12 @@ function reminder_form(&$node) {
     );
   }
 
-  if ($type->has_body) {
-    $form['body'] = array(
+  $form['description'] = array(
       '#type' => 'textarea',
       '#title' => t('Add some description'),
-      '#default_value' => isset($node->body) ? $node->body : '',
+      '#default_value' => isset($reminder['description']) ? $reminder['description']: '',
       '#rows' => 5
-    );
-  }
+  );
 
   if ((isset($node->nid) && $node->uid == 0) || $user->uid == 0) {
     $form['anonym'] = array(
@@ -257,7 +255,6 @@ function reminder_validate($node, $form, &$form_state) {
  * @todo
  *   Refactor.
  *   Date, remind and subscribe widgets.
- *   Save and update body/description.
  */
 function reminder_node_submit($node, $form, &$form_state) {
   // No preview available.
@@ -275,7 +272,6 @@ function reminder_node_submit($node, $form, &$form_state) {
   }
 
   $node->title = $form_state['values']['title'];
-  $node->body  = $form_state['values']['body'];
 
   if ($node->nid == NULL) {
     global $user;
@@ -298,6 +294,7 @@ function reminder_node_submit($node, $form, &$form_state) {
       'admin_url'    => $admin_url,
       'anonym_name'  => $anonym_name,
       'anonym_email' => $anonym_email,
+      'description'  => $form_state['values']['description'],
     );
 
     $query = db_insert('reminder')->fields($values);