Two used functions do not work / exists in the modal_entityform.module.

Both can be found in the modal_entityform_access function:

function modal_entityform_access($op, $entityform) {
  if (!entityform_access($op, $entityform)) {
    return FALSE;
  }
  $rule_result = entityform_invoke_rules($entityform, 'access_rules');
  return _entityform_rules_all_pass($rule_result);
}

entityform_invoke_rules does not exist.
_entityform_rules_all_pass does not exist.

I'm using the latest versions of entityform.

CommentFileSizeAuthor
#2 modal-entityforms2.patch1.71 KBskadu

Comments

maximpodorov’s picture

Title: Undefined functions in modal_entityform » Support both versions of entityform module

Yes, the problem is the different versions of the Entityform module. Version 1 contains these functions, version 2 does not.

skadu’s picture

StatusFileSize
new1.71 KB

Hi there maximpodorov, love the module, this is exactly what I am looking for to use with entity forms. As with Anybody here, I am using the 2.x branch of entityforms and can not go back to the 1.x branch. As mentioned above, the access check section you have in your module does not use the new functions.

Entityforms removed it's requirement on rules, and that functionality was spun into it's own module, entity_rules. It has equivalent functions that execute rules but required some other changes.

Attached is a patch that will work with Entityforms 2 (mostly), it will correctly execute rules, however, I am still having another issue where the ajax response does not cause a page load when it is supposed to. I think there is an issue in the commands array being passed back through, but I will dig into that in a separate issue.

I wanted to provide you with the changes needed to get rules execution working with entityform 2. Attached is a patch that enables that.

The changes occur in two main places:

The modal_entityform_page_submit function

  • We need to pass the fully loaded entityform entity to the modal_entityform_access function, so I swapped out "$entityform" which was not loaded, with the already existing "$entityform_type_entity"

The modal_entityform_access function

  • We need to swap the function "entityform_invoke_rules" with "_entity_rules_invoke_rule" and pass it the correct parameters
  • The parameters are the fully loaded entityform object, the correct entity type "entityform" and the update operation being performed which in this case is "form_access"

This allows the access rules to fire off and should give you a headstart on getting this to work with the new version of entity forms.

I am however still have a problem on the submit side of things. The form calls the ajax submit URL, but does not cause the page to refresh, or really return anything from the ajax call. The submission occurs (I can see the submissions on the entity form submissions page, but nothing is returned from the ajax call. I am still working through that and will try to follow up with any findings.

Thanks again for your help, hope this is of use to you.

skadu’s picture

Just a quick follow up to my note above, the submission error I am having is related to the clientside_validation module. Still investigating...

skadu’s picture

So my issue has something to do with the way the $command array is being passed on the form submit. I had to ensure it was empty during the second round of process. Otherwise, it has erroneous items in it due to the I believe the ctools_modal_form_wrapper being called. Apologies if I am way off, but by emptying out the command array prior to the additional redirects and modal_message commands being added on, I do not run into any issues.

$commands = array_merge(ctools_modal_form_wrapper('entityform_edit_form', $form_state), $extra_commands);
  if (!empty($form_state['executed']) && empty($form_state['rebuild'])) {
    $commands = array();
anybody’s picture

The patch above works great for my problem!

maximpodorov’s picture

Status: Active » Fixed

The code is committed to support both versions of Entityforms module. I close the issue now. Please reopen if the problem remains.

Status: Fixed » Closed (fixed)

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

kopeboy’s picture

Priority: Normal » Major
Status: Closed (fixed) » Needs work

Installed the modules today and still doesn't work.

entityform 7.x-2.0-rc1
modal 7.x-1.x-dev
modal_entityform 7.x-1.x-dev
modal_forms 7.x-1.2

I created an EF with machine name "test_form"
I am building my link like this:
<a href="modal/entityform/test-form/nojs/0" class="ctools-use-modal ctools-modal-modal-popup-small">Click 1</a>
or like this: <a href="/modal/eform/submit/test-form/nojs/0" class="ctools-use-modal ctools-modal-modal-popup-small">Click 2</a>
and they both dont work - this error will show in a browser popup:

An AJAX HTTP error occurred.
HTTP Result Code: 404
Debugging information follows.
Path: modal/entityform/test-form/ajax/0
StatusText: Not Found
ResponseText: 
Page not found
...
.....

How to fix?
Is there anything more I need to add in custom code?
Any dependency?

maximpodorov’s picture

<a href="modal/entityform/test-form/nojs/0" class="ctools-use-modal ctools-modal-modal-popup-small">Click 1</a>

I see no leading slash in the address.
Is the machine name of your form "test-form"? Usually, it can't contain dash symbol.

So, please try this address:

<a href="/modal/entityform/test_form/nojs/0" class="ctools-use-modal ctools-modal-modal-popup-small">Click 1</a>
kopeboy’s picture

the machine name is test_form but the URL would become test-form.

Actually I am now investigating my theme (Radix) because other modals dont load either.
Will come back soon. Thanks for your fast reply!

kopeboy’s picture

Priority: Major » Normal
Status: Needs work » Closed (fixed)

Ok. My error. The problem was with the Radix theme.

I solved upgrading to their latest dev version, and now
modal & modal_entityform work right out of the box, also with correct Boostrap modal styling.

Please can you clarify in your module's page that "modal_forms" module is not needed?
Thanks!

maximpodorov’s picture

Hmm, I can't list all the modules which are not required. :)

nicolas bouteille’s picture

I found your module reading this post. http://drupal.stackexchange.com/a/108956/30402
I agree that if Modal forms is not required you could mention it. You don't need to talk about all the modules that are not required, just those that people get confused with ;)