Note that there are some explanatory texts on larger screens.

plurals
  1. POprovide own unapply method in play framework 2 with scala and circumflex-orm class
    text
    copied!<p>I want to combine the form binding from play 2.0 framework with a class extending Record from the circumflex-orm (<a href="http://circumflex.ru/projects/orm/index.html" rel="nofollow">website</a>).</p> <p>These are my class objects:</p> <pre><code>class Task extends Record[Long, Task] with IdentityGenerator[Long, Task] { def this(name: String, description: String) = { this() this.name := name this.description := description } val id = "id".BIGINT.NOT_NULL.AUTO_INCREMENT val name = "name".VARCHAR(255).NOT_NULL val description = "description".TEXT.NOT_NULL def PRIMARY_KEY = id def relation = Task } </code></pre> <p>And this is what i try to do with the play form:</p> <pre><code>val taskForm: Form[Tasks] = Form( mapping( "name" -&gt; text, "description" -&gt; text ) {(name, description) =&gt; Task(name, description)} {(t: Task) =&gt; Option(t.name(), t.description()) } ) </code></pre> <p>But i get an error like this:</p> <pre><code>found : models.Task =&gt; Option[(String, String)] required: Unit =&gt; Option[(String, String)] {(t: Task) =&gt; Option(t.name(), t.description())} </code></pre> <p>And if i replace Option by Some:</p> <pre><code>found : models.Task =&gt; Some[(String, String)] required: Unit =&gt; Option[(String, String)] {(t: Task) =&gt; Some(t.name(), t.description())} </code></pre> <p>I am clueless right now and any hint would be appreciated.</p> <p>Thanks a lot.</p> <p><strong>EDIT:</strong> I made a basic error, i did name the Form: </p> <pre><code>val taskForm: Form[Tasks] = Form( </code></pre> <p>when the name of the class is "Task". So i can change it to:</p> <pre><code>val taskForm: Form[Task] = Form( mapping( "name" -&gt; text, "description" -&gt; text ) ( (name, description) =&gt; Task ) ( (t: Task) =&gt; Option() ) ) </code></pre> <p>And now i get a different error:</p> <pre><code>Unspecified value parameter x ( (t: Task) =&gt; Option() ) </code></pre> <p>I made a simple project with the needed dependencies in eclipse, you can download it here and look at it, if it helps: <a href="http://sveri.de/files/public-docs/sonstiges/FormBindOrmExample.zip" rel="nofollow">Basic Form Example</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload