I've followed Leighton Whiting's tutorial exactly:
https://vimeo.com/29735537

Except whenever I enter my message into the Protected Message field in Manage Display, it won't save it. It repeatedly forces me to select the Text format as well, and then doesn't save my setting for that either.

I've tried every available text format as well. (See screenshots)

Comments

jasonaaronwood created an issue. See original summary.

jasonaaronwood’s picture

I began looking at the code for ms_ppv.module, for the newest version, and began comparing it to an earlier MoneyScripts version of the module from 2015, and I did notice one difference:

Moneysuite PPV: Line 2088 to 2091:

: '',
        '#format' => isset($group->format_settings['instance_settings']['format']) ? 

$group->format_settings['instance_settings']['format'] : 1,
        '#element_validate' => 

array('_text_format_validate'),
      );

This setting is in the current 7.x-10.4 version, and causes the field_group's Text Format to need to be set, and it never saves.

Whereas...
Moneyscripts PPV (old version 2015): Line 2073 to 2074:

: $formatter['instance_settings']['message'],
      );

Replacing the code in the current version with this code causes the field_group's Text Format to default to Filtered HTML (and stays that way even if I try to change it to something else).

It still doesn't SAVE the text or code that I type into the Protected Message field, but I think I did manage to locate a piece of what's causing part of the problem.

jasonaaronwood’s picture

Ok so I decided to try uploading the old 2015 version of ms_ppv.module, overwriting the newer one, and it fixes the problem.

1. It removes the Text Format drop-down menu entirely from the Protected Message field, while still recognizing and rendering HTML.
2. It saves the information I enter into the Protected Message field.
3. It displays properly when saved.

(This is really important functionality because PPV, when applied to one content type that appears as an Entity Reference within another content type, displays the full title of the referenced entity. For an online course (like what I'm using it for), giving away all of the content names to users who haven't paid yet could potentially tell the potential customer a summary of everything in the course and negate their need to pay for it. Being able to use a PPV-protected field_group to contain the protected fields helps hide all of the info until after the customer has paid.)

I'd like to attach my original MoneyScripts version of the Pay Per View module file, in case anyone else is experiencing this problem (but it won't let me). I was able to simply upload that version and overwrite the current Moneysuite version and it fixed the problem.

Here is a link to mine: http://shredmentor.com/sites/all/modules/moneysuite/ms_ppv/ms_ppv.module

Farreres’s picture

The text format option was added to make this text field behave in a drupal standard way.

I am myself using it and I find no problem at all with this. But I am using it with a single field, not a fieldset.

I am not going to remove this update which works perfectly for single fields. I will instead check what happens for field groups and try to correct it.

In the meanwhile, do you really need it for a fieldgroup or can you redesign your contents to move it into single fields?

Farreres’s picture

I think that it is important to have the possibility of controlling the behavior of text fields, we only need to make it work correctly.

Checking the code, the problem must be in the interaction of four functions:

-ms_ppv_field_group_formatter_info() that exposes Field API formatter types.
-ms_ppv_field_group_format_settings() which defines configuration widget for the settings on a field group formatter.
-ms_ppv_field_group_pre_render() which allows to create the given wrapper element that can contain the fields.
-_text_format_validate() which converts the custom field values so they can later be used by ms_ppv_node_load(), ms_ppv_node_insert(), ms_ppv_node_update(), ms_ppv_node_view(), ms_ppv_get_type_defaults(), ms_ppv_form_alter(). The function does it correctly for single fields but I think it is making it wrong for field goups. My opinion is the problem comes from this function. Field groups are not that well documented in drupal info pages and most of the time it's guesswork. Maybe someone can help me to enhance the code to make fieldgroups work correctly. I will do my best anyway but some help would be greeted.

Also, upon checking function ms_ppv_field_group_format_settings($group) I can see one line that may need editing, but this surely is not the source of the problem:

Line 2088:
'#default_value' => isset($group->format_settings['instance_settings']['message']) ? $group->format_settings['instance_settings']['message'] : '',

my need to be changed into (I doubt this really has an impact on the error we are discussing):

'#default_value' => isset($group->format_settings['instance_settings']['message']) ? $group->format_settings['instance_settings']['message'] : $formatter['instance_settings']['message'],

jasonaaronwood’s picture

Thank you for that - I will try this edit and see if it does the trick (I've still been using the old MoneyScripts PPV version since I made this post).

Farreres’s picture

Well, this edit is not going to solve anything. The problem comes from interactions among the functions named in #5. The problem is that fieldsets are not well documented in drupal API and it's difficult to develop as it was with single fields.

pamigo’s picture

jasonaaronwood, I need this old file. There is the same version of ms_ppv.module in all releeses now. Even the first one...

Your link att #3 is not working any more...

Please help me!