I've got a custom field that has a textarea in the form but the html tags are being escaped. How can I set it up so that it either won't do that or that the user can select an input filter that will allow certain html tags?
Update: Looking through the text.module file, I see a type called "text_format" which I'm trying to use on the form:
$widget['download_content'] = array(
'#title' => t('Content'),
'#type' => 'text_format',
'#default_value' => isset($items[$delta]['download_content']) ? $items[$delta]['download_content'] : NULL,
'#format' => isset($items[$delta]['format']) ? $items[$delta]['format'] : NULL,
'#base_type' => 'textarea',
);
The widget now displays correctly but there are SQL errors when saving:
PDOException: SQLSTATE[21S01]: Insert value list does not match column list: 1136 Column count doesn't match value count at row 1: INSERT INTO {field_data_field_page_premium} (entity_type, entity_id, revision_id, bundle, delta, language, field_page_premium_download_fid, field_page_premium_cover_fid, field_page_premium_download_content, field_page_premium_format) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8_value, :db_insert_placeholder_8_format, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => node [:db_insert_placeholder_1] => 6 [:db_insert_placeholder_2] => 6 [:db_insert_placeholder_3] => page [:db_insert_placeholder_4] => 0 [:db_insert_placeholder_5] => und [:db_insert_placeholder_6] => 11 [:db_insert_placeholder_7] => 12 [:db_insert_placeholder_9] => [:db_insert_placeholder_8_value] => this<br />is<br/>test<br />content [:db_insert_placeholder_8_format] => plain_text ) in field_sql_storage_field_storage_write()
Comments
_
select 'filtered text' instead of 'plain text' in the settings for the field. Also, since this isn't a code question, I've moved it the the correct forum.
this is a code question. will
this is a code question. will you move it back please? i am defining a textarea in my module that creates a custom field.
If this is custom code, then
If this is custom code, then it has to do with the codes handling of the text field.
_
It wasn't when you first posted it, lol.
Please Elaborate
Hi,
Please post the context :)
What does this mean ?
Are you writing a module which implements a custom content type with the Drupal 7 field API? If so, which hook are you implementing in the code above?
In other words, please elaborate and give us the context :)
Sorry about that. Yes, I am
Sorry about that. Yes, I am adding a custom field with the field API. The code above is in the hook_field_widget_form function.
No Problem
Hi,
Thank you.
Can you please post the rest of your hook_field_widget_form() implementation.
Do you have more than 1 widget type defined? Could you post your hook_field_widget_info() implementation ?