0

I'm a drupal newbie. In Drupal 7, I have an install file and I'm trying to get the schema to work for a text_with_summary.

Maybe I'm going about this the wrong way but I am using a form's install file to create the databases I will need. I just can't seem to get the "body" (called another name) field to work with text_with_summary.

apaderno
  • 28,547
  • 16
  • 75
  • 90
purplerice
  • 473
  • 1
  • 6
  • 22

1 Answers1

2
I am using a form's install file to create the databases I will need.

Do you mean a module's install file (not being picky just trying to make sure we're talking about the same thing)?

text_with_summary is not valid in a Drupal database schema (unless you're talking about a field schema but you surely would have mentioned that if you were). All valid field types for hook_schema() are listed on the Schema API page. text_with_summary is a widget type, not a database field type.

Posting some code would help an awful lot in trying to work out what you're trying to accomplish.

UPDATE

This will declare a table with an ID field and a text column suitable for holding the rich text you need:

function MYMODULE_schema() {
  $schema['my_table'] = array(
    'description' => 'Table description',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE
      ),
      'text_column' => array(
        'type' => 'text',
        'size' => 'big',
        'not null' => TRUE
      )
    ),
    'primary key' => array('id')
  );

  return $schema;
}

The Schema API is in invaluable reference page for this sort of thing.

When you want to display your form you'll probably want to look at the Form API documentation, particularly the drupal_get_form() function.

Hope that helps, downloading the Examples module would also be a very good idea, it has tons of well documented Drupal code examples.

Clive
  • 36,918
  • 8
  • 87
  • 113
  • Wow - thanks for answering so fast. You're already making it clearer. OK - so text_with_summary is not valid in schemas (which explains why I was not able to find it searching). – purplerice Sep 09 '11 at 15:17
  • No problem I use Drupal for a large part of my working life, what exactly are you trying to do here? – Clive Sep 09 '11 at 15:24
  • Wow-thanks for answering so fast. I didn't realize it wasn't a valid field schema-which explains why I couldn't find it searching. Yes, I do mean a module's install file:) What I'm trying to do is prepare a table with the fields I will need, one of which is I'm used to calling a "rich-text" field but is the same type as a Body field in Drupal. Several steps later, when other fields are populated, a user would get this field in a form. I apologize in advance for my terminology - I'm still getting used to "drupalese". So is what I'm looking for is accomplished with a text type field? – purplerice Sep 09 '11 at 15:30
  • Sorry I'm still not really sure what you're trying to do when you say you're trying to prepare a table do you mean a database table? – Clive Sep 09 '11 at 16:34
  • Yes - a database table. I'm not populating all of it yet - just creating the columns for later use. – purplerice Sep 09 '11 at 17:54
  • OK I think I get it, I'll update the previous answer with some code that might help – Clive Sep 09 '11 at 18:29