Please find the attached patch file to be ported to make the module work as said.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | taxonomy_add_previous_2.patch | 3.28 KB | sanchi.girotra |
| taxonomy_add_previous_1.patch | 877 bytes | sanchi.girotra |
Please find the attached patch file to be ported to make the module work as said.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | taxonomy_add_previous_2.patch | 3.28 KB | sanchi.girotra |
| taxonomy_add_previous_1.patch | 877 bytes | sanchi.girotra |
Comments
Comment #1
joachim commentedThanks!
But could you explain what this fixes please?
Comment #2
sanchi.girotra commentedHi @joachim,
When i used this module i found that after clicking on "Save and add similar" button in add taxonomy form, term get saved but the content of the previous term don't come auto filled when the form for next term get loaded again.
So as to fix this issue i provided the above patch.
Thanks And Regards
Sanchi
Comment #3
joachim commentedSo... you're saying the module doesn't work at all? That's odd, as I've tested it and it works for me.
The issue title should describe the problem to be fixed. Also, set the category: this should be a bug report.
I think it's cleaner to get the fields from the field info API. The $term object will have other things on it such as the tid, which we don't want to bring over!
Could you explain why the process function isn't working? Also, if your patch makes the module cease to use a function, you should also remove it.
Comment #4
sanchi.girotra commentedHi @joachim,
1.
$fields = field_info_instances('taxonomy_term', $vocabulary_name);I have not used this because it returns empty array as field_info_instances() calls _field_info_collate_fields() which returns
... [instances] = array(
.... [taxonomy_term] => Array
(
[tags] => Array
(
)
) ...
i.e. don't go in any condition in field_info_instances().
2.I have not used process function bacause :
if (array_key_exists('#default_value', $element) && array_key_exists('#value', $element)) {any process function call will not go in this condition as #value of a newly created element is always empty.
$matching_fake_form_element = drupal_array_get_nested_value($form_state['taxonomy_add_previous_previous_term_form'], $element['#array_parents']);this will set $matching_fake_form_element as
Array
(
[#type] => textfield
[#title] => Name
[#default_value] =>
[#maxlength] => 255
[#required] => 1
[#weight] => -5
)
having #default_value as empty.
$element['#value'] = $matching_fake_form_element['#default_value'];so this will set $element['#value'] to null.
Please find the new patch having no process function.
Thanks And Regards
Sanchi
Comment #5
joachim commentedCould you possibly edit your comment and use code tags to make it a bit more readable please?
Also, the status for this should be 'needs review'. You'll find an explanation of issue statuses here: http://drupal.org/node/156119
Comment #6
joachim commented> I have not used this because it returns empty array
I don't understand what you mean here.
field_info_instances() returns an array of fields. It's the correct way to get the list of fields for the current term.
> if (array_key_exists('#default_value', $element) && array_key_exists('#value', $element)) {
> any process function call will not go in this condition as #value of a newly created element is always empty.
That's fine. That's why I'm using array_key_exists() rather than !empty().
Comment #7
sanchi.girotra commented1.
explanation of how it all woks:
when the function
taxonomy_add_previous_form_taxonomy_form_term_alter(&$form, &$form_state, $form_id) {callsfield_info_instances('taxonomy_term', 'tag');2.
if (array_key_exists('#default_value', $element) && array_key_exists('#value', $element)) {but there is no array corresponding to #value or #default_value, you can see this by displaying the content of $element.
Thanks for guiding me.
Comment #8
joachim commentedIt should be 'tags' for the OOTB vocab, not 'tag'.
gets me an empty array, but that's because on my site I have no fields defined on the tags vocab. That's normal.
Comment #9
sanchi.girotra commentedYes ,it should be 'tags' its my mistake .
But drupal standard profile provides us default vocabulary "tags" having fields name,description, url, parent.
So now what we should do to get data through field_info_instances('taxonomy_term', 'tags') ??
Comment #10
joachim commented> name,description, url, parent
Those aren't FieldAPI fields. Also, I didn't think those should be copied: the url and name need to be unique, at least.
Comment #11
sanchi.girotra commented@joachim,
Most of us use these default fields only with in the 'tags' vocabulary so your module should work with that also.
So finally is this patch worth it ??
Comment #12
joachim commentedI can see that you might want the same parent for the next term -- so if that's the actual problem you are trying to solve, you could rework the patch to fix that (and update the issue title too).
But would you really want to repeat the description?
Comment #13
sanchi.girotra commented@joachim,
No, i want same data for name, desc, url, parent i.e. all fields should come for the next term which user can change accordingly.
I think this is what your module desc says
Regards
Sanchi
Comment #14
joachim commentedI can see that you might want these to be prefilled so the prefilled value can then be altered by the user before saving.
I'm a bit concerned that at this point, it might be a good idea to stick some sort of visual warning on anything that's been prefilled, but that's going to be pretty messy to do.
At any rate, I am about to change the way this works completely to fix #1617956: doesn't work on multi-select widgets, so this patch will need work.
Comment #15
joachim commentedBetter title.