Is it possible to configure the drupal node link and pass your search and argument from another field

I am trying to create a custom form in drupal with a node field.

I would like to add some extra functionality to the autosave node. I created a view containing an argument. I would like to pass this argument from the drop down list as well as the typed text into an autocomplete script.

Does anyone know how I will start to do this.

/* FIELD 1 - the drop down */ $sql = "SELECT nid, title FROM node where type='resourcetype' AND status =1 order by title "; $result = db_query($sql); $counter = 0 ; $options = array(); while ($data = db_fetch_array($result)) { // krumo ($data); $options[$data[nid] ] = $data[title] ; if ($counter ==0 ) {$df = $data[nid]; } $counter ++; } /* FIELD 2 - the node reference field */ $form['sor']['type'] = array( '#type' => 'select', '#title' => t('Resource type'), '#required' =>TRUE, '#options' => $options, ) ; $form['sor']['field_asor_sors'] = array( '#type' => 'textfield', '#title' => t('Add a SOR item to this job'), '#autocomplete_path' => 'nodereference/autocomplete/field_asor_sors', '#element_validate' => array('myelement_validate_is_valid_noderef'), '#required' =>TRUE, ); 

Many thanks

Matt

+2
source share
2 answers

AFAIK there is no easy way to do this.

I wanted to do something similar some time ago (using different arguments based on the node context), but refrained from doing so, as this would require significant changes to the autocomplete callback logic. You will need to modify several nodereference functions to add support for passing the argument to the initial nodereference_autocomplete() , passing it from there to _nodereference_potential_references() and finally to _nodereference_potential_references_views() , ensuring that the changes are not violated by anything else.

If you want to try, you should take a look at the patches in this thread , as they also want to do something like that, which may contain some useful hints / examples.

A potentially simpler alternative would be to exchange the #autocomplete_path callback of the #autocomplete_path field with your own custom version, which will generate the result by adding js logic to the drop-down menu to add an additional argument to this path when changing the selection.

+2
source

If you go into the numbering field configuration form and scroll to the end, a set of fields (which can be collapsed) called β€œExtended nodes” that can be referenced (View) appears. ”You can use this to select a view and to this view was the source of numbering choices without writing new code.

-1
source

Source: https://habr.com/ru/post/1306168/


All Articles