I've just installed the Terms Fields module.

I added a new field of type: Multi-row textarea

Problem is, I need to add a wysiwyg on this field so that an admin can add html.

Is this possible???

Please help.

Comments

harcher’s picture

Basically, I don't see the option "Input format" under this new field when editing a term.

Can I add it?

seb7’s picture

That would be handy to have that ...

seb7’s picture

Status: Active » Needs work

You just have to add

	$form['fields']['format'] =  filter_form(); // to integrate wysiwyg

on line 122 in term_fields.module

so

          case 'textarea':
            $form['fields'][$fid] = array(
              '#type' => $field->type,
              '#rows' => 5,
              '#cols' => 60,
              '#default_value' => $value ? $value : NULL,
              '#description' => $field->description,
            );
            break;

becomes

          case 'textarea':
            $form['fields'][$fid] = array(
              '#type' => $field->type,
              '#rows' => 5,
              '#cols' => 60,
              '#default_value' => $value ? $value : NULL,
              '#description' => $field->description,
            );
	$form['fields']['format'] =  filter_form(); // to integrate wysiwyg
             break;
copyhold’s picture

Does not work if there are more then one textarea field

b-prod’s picture

Title: Term fields and input format » Add input format form to textarea fields
Version: 6.x-1.8 » 6.x-1.x-dev
b-prod’s picture

What is required for such behavior:
- add a checkbox in the field creation form to specify if the format options should be displayed or not
- for textarea fields, add an additional column in database table to store the format
- modify the field rendering to take care of textarea format if any

The second point means large changes in the way to store the fields data. I think it should probably be a separate issue.

You would be involved in such development?

jdln’s picture

Subscribing

lcampanis’s picture

I came accross this problem, and no one seems to post the right solution with a nice explanation. So here it goes...

To have a multiple textareas with input formats available for more than one textarea in your module, the input format, when declared, needs to know its parent(s), so it can look for a textarea inside that scope. When you have more than one textarea and need an input format, consider doing the following:

<?php
// first textarea
$form['scope1']['scope1.1']['text'] = array(	'#type' => 'textarea',
									'#title'   => t('A title'),
 									'#weight' => 2,
								); // notice weight == 2
	
$form['scope1']['scope1.1']['format'] = filter_form(2, 3, array('scope1','scope1.1','format')); // to integrate wysiwyg

// second textarea
$form['scope2']['scope2.1']['text'] = array(	'#type' => 'textarea',
									'#title'   => t('A title'),
 								 	'#weight' => 8,
								); // notice weight == 8
	
$form['scope2']['scope2.1']['format'] = filter_form(2, 9, array('scope2','scope2.1','format')); // to integrate wysiwyg
?>

What you need to watch here are the weights. For your input format to appear under the designated textarea, it needs to have the next consecutive weight.

Enjoy!

b-prod’s picture

Title: Add input format form to textarea fields » Add input format form to textarea fields [solution]

Actually this is only hack for one-time uses.
What is really necessary would be to create a patch against the dev version to handle formats in the way described in #6.
Otherwise I will not be able to port anything into the term_fields code.

jayboodhun’s picture

Thanks kiela69,

This solution worked for me :)

Jay

liquidcms’s picture

sadly it seems like filter_form() returns all available (by role) formats and that it is not possible to limit to only specific formats; i think i need to go through returned array and remove the formats i don't need. would be good if this function allowed passing array of formats required.

b-prod’s picture

@liquidcms : Have a look on better_format module, it could probably help you.

liquidcms’s picture

how could better formats help? do they have an api that makes this easier?

b-prod’s picture

@liquidcms: There is no API, but extending the code is possible.

I think it could be easy to implement a new mode of your choice for better format. Existing modes are 'node', 'block' and 'comment'.

A simple hook_form alter() on "better_formats_defaults_admin_form" form ID with addition of better_formats_get_role_default_fields('your_format') to the form and a validate and a submit handler could be suffisant.

To get the expected formats for current user you use:
better_formats_get_default_format('your_format'):

Please open a new support request in better format issue queue if you need more help and copy there last 3 comments of this discussion, because here we are supposed to work on term fields issues:)

harcher’s picture

@B-Prod: Seems to me you could implement this with your eyes closed. You should give it a go :)

b-prod’s picture

Version: 6.x-1.x-dev » 6.x-2.x-dev
Component: Miscellaneous » Code
Category: support » feature
Status: Needs work » Fixed

This feature has been added in the 2.x branch, which need now some testing before its first stable release.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.