Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi,
I have a problem using Edit module. Everything works great, but I must create custom validation's function which validate fields relative to others.
For example, I want to compare value of field_test_1 to value of field_test_2 to decide if I validate field_test_1 or not. But when we save inline a node, each fields are validated independently, so I can't do what I want.
Is there a way to access all form's fields values when we save a node after editing several fields?
Thanks for your help and sorry for my bad english...
Comments
Comment #1
sjeandroz CreditAttribution: sjeandroz commentedhi,
nobody can help me?
I think it's not something so complicated, and I think I'm not the only one who want to do something like that...
thanks and sorry for my bad english
Comment #2
Wim LeersIf you use in-place editing, all fields must be independently validatable. If that's not the case, then you cannot use in-place editing.
However, in your case it sounds like you could just load the existing node, look at fields' values for other fields than the one being in-place edited, and just get the data from there.
Comment #3
sjeandroz CreditAttribution: sjeandroz commentedHi Wim Leers,
Thanks for your response,
Yes the method you advise me is what I finally do and it works.
Thanks!
Comment #4
Wim LeersYou're welcome!
Comment #5
Wim LeersOh, now that I think about it, what I said is actually wrong. For correctness, you should retrieve the entity-being-edited from CTools' TempStore instead. Because that other field's value may have been changed also, but is not necessarily already saved to the database.
Comment #6
sjeandroz CreditAttribution: sjeandroz commentedI understood what wou want to say. My code is the following to retrieve the other fields:
ctools_include('object-cache');
$tempstore_id = _edit_entity_tempstore_id("node", $form_state['entity']->nid);
$node = ctools_object_cache_get('edit', $tempstore_id);
Comment #7
Wim Leers#6: perfect :)