Before I post a patch I thought I would post it here to vet out the best way to do this.
If we change function theme_paragraphs_field_multiple_value_form($variables) { and make &$variables a reference then you would be able to call: hook_preprocess_paragraphs_field_multiple_value_form(&$vars) and just create the text you want.
$vars['add_text'] = 'This is my new text.';
or
$add_text = variable_get('paragraphs_add_more_text', NULL);
and let others just set a variable.
This would need to change a bit as well
$output = '<div class="form-item">';
if (count($items)) {
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('field-multiple-table'))));
}
else {
$output .= '<label>' . t('!title !required', array('!title' => $element['#title'], '!required' => $required)) . "</label>";
if (isset($add_text)) {
$output .= '<p><em>' . t($add_text) . '</em></p>';
}
else {
if ($add_mode == 'button') {
$add_text = 'No !title_multiple added yet, press a button below to add one.';
}
else {
$add_text = 'No !title_multiple added yet. Select a !title type and press the button below to add one.';
}
$output .= '<p><em>' . t($add_text, array('!title_multiple' => t($instance['settings']['title_multiple']), '!title' => t($instance['settings']['title']))) . '</em></p>';
}
}
$output .= $element['#description'] ? '<div class="description">' . $element['#description'] . '</div>' : '';
$output .= '<div class="clearfix">' . drupal_render($add_more_button_type) . drupal_render($add_more_button) . '</div>';
$output .= '</div>';
Let me know what you think, I need to patch this for OA.
Thanks
-Scott
Comments
Comment #1
scottalan commentedComment #2
scottalan commentedComment #3
nevets commentedI would like to see this as a field setting, so each paragraph field could have there own unique text with html allowed.
Comment #4
scottalan commentedComment #5
scottalan commentedHere's a patch. Let me know if you feel anything needs to be changed.
Thanks,
-Scott
Comment #6
jeroen.b commentedCan you add backwards compatibility and a default value? (Existing fields should stay the same after an update)
Comment #7
nevets commentedWorks for me, some suggested changes.
Use a textarea instead of textfield, it will allow for more visible text. I did this plus set '#rows' to 3.
I changed the title to 'Paragraph Instructions' since 'Help text' already appears on the form as part of core.
And I changed the description so instead of starting with 'This', it starts with 'When there are no existing paragraphs, this' to make it clearer when the text is show. End result for the element is
Comment #8
scottalan commentedI have a new patch ready. I'll get it up later this morning, thanks!
Comment #9
scottalan commentedThis patch will allow backwards compatibility. I added another settings field to handle actually hiding the 'Paragraph instructions' all together. This field seemed necessary since the default was to display the text. I can't base it off of the fact the Paragraph instruction textarea is empty. This provides a simple checkbox that allows hiding the instructions.
Comment #10
mpotter commentedWe are using this in Open Atrium, so setting correct status for other review. Would be good to get this in the next release.
Comment #11
jeroen.b commentedAnyone wants to re-roll? Code looks fine to me.
Comment #12
mpotter commentedI think this is a good re-roll against the latest dev and also adds a missing check_plain from #9 and changes the !var to @var as in the current dev.
Comment #13
mpotter commentedLooks like I missed changing !title to @title here and on the line below.
Comment #14
mpotter commentedHere is a reroll against 1.0-rc5 that also fixes the comment in #13.
Comment #16
jeroen.b commentedWe are working on a test for this now.
Comment #17
jeffm2001 commentedRe-rolled this patch against the latest dev
Comment #18
bluegeek9 commentedUnfortunately, Drupal 7 is End of Life and no longer supported. We strongly encourage you to upgrade to a supported version of Drupal.