0

I tried to send the value of an input field to a cypher query. For example when the user introduces a technology and clicks the submit button must appear a list of the assigned programmers. This code is at submit button:

match (technology:Technology {name: ${technology.name}})<-[skill:SKILL]-(Programmer) return Programmer,skill,technology

In the input field i set the value with ${technology.name}.This is the generated code:

 <div>
                <form action="/search" method="POST" data-structr-attr="technology">
                    <input value="" data-structr-name="technology">
                    <input type="submit" value="submit">
                </form>
            </div>

The problem is that nothing happens. Does anyone know where I did wrong? Thank you.

1 Answers1

3

In order to POST the technology value using an HTTP form, you need to set the name attribute of the input field to "technology". The mistake in the above code is that you set data-structr-attr, but not name, which is on the "HTML Attributes" tab:

<div>
    <form action="/search" method="POST">
        <input type="text" name="technology">
        <input type="submit" value="submit">
    </form>
</div>

Also, you wrote that the Cypher statement is on the submit button. In order for the search to work, you will need to configure the search page (the page that the form refers to in the action attribute) so that it uses the value from the form. The Cypher statement must be somewhere in the search page and not in the submit button.

  • On the search page should I enter a script and put inside it the query? It's ok how I wrote the cypher query? – Madalina Cristina Jun 10 '17 at 19:34
  • 1
    You should use a repeater on the search page, just put the Cypher query into the "Cypher Query" input field in the "Query and Data Binding" tab of a `
    ` element or any other element that should display the results. The query looks good.
    – Christian Morgner Jun 10 '17 at 19:55
  • And now I got this : Error while rendering node 998b7fe591014a649d745de5171914da: Invalid input '}': expected whitespace, comment or an expression (line 1, column 37 (offset: 36)) "match (technology:Technology {name: })<-[skill:SKILL]-(programmer:Programmer) return Programmer" ^. It seems that doesn't take the attribute from the input field. – Madalina Cristina Jun 10 '17 at 20:44
  • 1
    You need to put the Cypher query in the "Cypher Query" input field under "Cypher Query" on the "Query and Data Binding" tab of a `
    ` node or any other HTML node.
    – Christian Morgner Jun 12 '17 at 06:24