[support] text_format, what column to save the format ?

Niek van der Steen nvdsteen at signet.nl
Thu May 5 11:14:43 UTC 2011


Hi,


I am developing my own field type.
It is using a text_format type textarea:

         $element['content'] = array(
             '#type' => 'text_format',
             '#title' => t('Tab Content'),
             '#default_value' => isset($items[$delta]['content_value']) 
? $items[$delta]['content_value'] : NULL,
             '#format' => isset($edit['format']) ? $edit['format'] : NULL,
         );

So far so good. This makes a WYSIWYG editor appear.

Now when I try to save a node with this field, it gives me an error that 
the column and value count do not match.
After examining the error, I see that the query expects a field to store 
the selected format in. So I changed my schema to include the format, 
but then it just adds another value (empty) for that field, and still 
one value extra for the format. Still the same error.

My schema hook looks like this:

         $schema['columns']['content'] = array(
             'type' => 'text',
             'not null' => FALSE,
         );

         $schema['columns']['format'] = array(
             'type' => 'varchar',
             'length' => '255',
             'not null' => FALSE,
         );

         $schema['indexes'] = array(
             'name' => array('name'),
             'format' => array('format'),
         );

         $schema['foreign keys']['format'] = array(
             'table' => 'filter_format',
             'columns' => array('format' => 'format'),
         );

But it's still not working, still the same error..

So how can I say drupal which field it should use to save the format of 
type 'content' in? I'm really stuck here, and google isn't giving me the 
information I was hoping for..


Thanks in Advance,

Regards,

Niek


More information about the support mailing list