Hi,
I found that a div having a class name "pre-instructions" is always printed in my forms, even if it's empty.

So, I dug into the form configurations and I saw the "Intro form instructions" textarea in the page to edit a form. It was empty. So, I continue to dug, but this time, into the module code to find the source of it and I found it in entityform.admin.inc at line 261 where the condition to show it or not is :
if (!empty($entityform_type->data['instruction_pre'])

The problem with this case is that $entityform_type->data['instruction_pre'] contains :

Array
(
    [value] => 
    [format] => filtered_html
)

In fact, it's not empty, even if the real value is empty because the format value will always contain something.

So, the fix I suggest is this:
if (!empty($entityform_type->data['instruction_pre']) && !empty($entityform_type->data['instruction_pre']['value'])) {

Tell me what you think about it.
Thank you!

Comments

franckylfs’s picture

Issue summary: View changes
tedbow’s picture

Thanks for posting this. I see the issue you are talking and it looks like your fix would work.

Can you post patch? Here are instructions: https://www.drupal.org/node/707484

Thanks

moriartie’s picture

Made a patch with the change described in #1

kenorb’s picture

Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, 3: entityform-hide-instructions-if-empty-2457737-3.patch, failed testing.

pakmanlh’s picture

Status: Needs work » Needs review
StatusFileSize
new737 bytes

The #4 patch works properly. I rerolled it to apply.
Many thanks!

Status: Needs review » Needs work

The last submitted patch, 6: entityform-hide-instructions-if-empty-2457737-6.patch, failed testing.

pakmanlh’s picture

Status: Needs work » Needs review
StatusFileSize
new668 bytes

Sorry, bad patch. This one apply against 7.x-2.x
Cheers

Status: Needs review » Needs work

The last submitted patch, 8: entityform-hide-instructions-if-empty-2457737-8.patch, failed testing.

pakmanlh’s picture

Version: 7.x-2.0-rc1 » 7.x-2.x-dev
Status: Needs work » Needs review

rodrigoaguilera’s picture

Status: Needs review » Reviewed & tested by the community

After using this patch for a while I can confirm that it works and seems correct.

joelpittet’s picture

Status: Reviewed & tested by the community » Needs review
StatusFileSize
new779 bytes
+++ b/entityform.admin.inc
@@ -263,7 +263,7 @@ function entityform_form_wrapper($entityform, $mode = 'submit', $form_context =
       '#markup' => "<div class='pre-instructions' >" . $entityform_type->get_prop('instruction_pre') . "</div>",

We should be able to just put in if (!$entityform_type->get_prop('instruction_pre')). That way we know if the content is empty or not. The return value will be '' which evaluates to FALSE.

How about this patch?

das-peter’s picture

Status: Needs review » Reviewed & tested by the community

Just stumbled across this too. I think the approach from #13 is the most straight forward and efficient.
I'd say good to go.

joelpittet’s picture

Status: Reviewed & tested by the community » Fixed

Thanks @das-peter, I've committed and pushed to the dev branch

  • joelpittet committed 2a50796 on 7.x-2.x
    Issue #2457737 by pakmanlh, moriartie, joelpittet: Intro form...

Status: Fixed » Closed (fixed)

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