diff --git a/paragraphs.module b/paragraphs.module index 0371aec..b67b31e 100644 --- a/paragraphs.module +++ b/paragraphs.module @@ -566,6 +566,21 @@ function paragraphs_field_instance_settings_form($field, $instance) { '#required' => TRUE, ); + $element['add_mode_instructions'] = array( + '#type' => 'textarea', + '#title' => t('Paragraph Instructions'), + '#rows' => 3, + '#description' => t('When there are no existing paragraphs, this text is displayed above the select list or buttons. e.g., "No Paragraphs added yet, press a button below to add one."'), + '#default_value' => isset($settings['add_mode_instructions']) ? $settings['add_mode_instructions'] : '', + ); + + $element['hide_instructions'] = array( + '#type' => 'checkbox', + '#title' => t('Hide paragraph instructions'), + '#description' => t('Do not display paragraph instructions.'), + '#default_value' => $settings['hide_instructions'], + ); + if (!count($bundles)) { $element['allowed_bundles_explain'] = array( '#type' => 'markup', @@ -1176,12 +1191,22 @@ function theme_paragraphs_field_multiple_value_form($variables) { $output .= theme('table', array('header' => $header, 'rows' => $rows, 'attributes' => array('id' => $table_id, 'class' => array('field-multiple-table')))); } else { - $add_text = 'No @title_multiple added yet. Select a @title type and press the button below to add one.'; - if ($add_mode == 'button') { - $add_text = 'No @title_multiple added yet. Select a @title type and press a button below to add one.'; + $output .= (!empty($element['#title'])) ? '" : ''; + // Make sure we aren't supposed to just hide the instructions. + if (empty($instance['settings']['hide_instructions'])) { + // Check for custom instructions. + if (!empty($instance['settings']['add_mode_instructions'])) { + $instructions = check_plain(rtrim($instance['settings']['add_mode_instructions'])); + $output .= '

' . t($instructions) . '

'; + } + else { + $add_text = 'No @title_multiple added yet. Select a @title type and press the button below to add one.'; + if ($add_mode == 'button') { + $add_text = 'No @title_multiple added yet. Select a @title type and press a button below to add one.'; + } + $output .= '

' . t($add_text, array('@title_multiple' => t($instance['settings']['title_multiple']), '@title' => t($instance['settings']['title']))) . '

'; + } } - $output .= '"; - $output .= '

' . t($add_text, array('@title_multiple' => t($instance['settings']['title_multiple']), '@title' => t($instance['settings']['title']))) . '

'; } $output .= $element['#description'] ? '
' . $element['#description'] . '
' : ''; $output .= '
' . drupal_render($add_more_button_type) . drupal_render($add_more_button) . '
';