Jump to:

3435 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » How do I get arround: "you also cannot past a variable into a variable"

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 779 Views
  • silk
    Avatar
    Community Member
    18 Posts

    How do I get arround: "you also cannot past a variable into a variable" Link to this post

    Hello,

    I have a page TippToppMatchesPage with

    static $has_many = array(
    'Matches'=>'TippToppMatch',
    );

    Each TippToppMatch (DataObject) has

    static $has_many = array(
    'Tipps' => 'TippToppTipp'
    );

    TippToppTipp is also a DataObject

    On TippToppMatchPage I want to show a list of all matches and the "tipp" (german for guessing/betting on a result) of the current user. Therefore, in the template I'd like to do something like this:

    <% control Matches %>
    <tr class="match">
    <td class="matchDate">$Date</td>
    <td class="tipp">Top.$TippOfCurrentUserForm($ID)</td>   
    <% end_control %>

    Unfortunately, this is not allowed since "you (...) cannot past a variable into a variable"
    I have found several posts where others had a similar problem, but there never was a solution other than "you have to find a way around it".
    Which way to proceed?
    TippToppTipp and TippToppMatch are DataObjects, the only Controller available is TippToppMatchesPage but I don't see how TippToppMatchesPage should be able to "see" which TippForm I want to show without using a parameter.

    Any suggestion, tutorial or hint?
    Thanks in advance,
    Christian

  • Willr
    Avatar
    Forum Moderator
    5490 Posts

    Re: How do I get arround: "you also cannot past a variable into a variable" Link to this post

    Well instead of passing an ID to an object you need to have the TippOfCurrentUserForm function on your TippToppMatch object.

    <% control Matches %>
    <tr class="match">
    <td class="matchDate">$Date</td>
    <td class="tipp">$TippOfCurrentUserForm</td>
    <% end_control %>

    Then have the TippOfCurrentUserForm function on the TippToppMatch.

  • silk
    Avatar
    Community Member
    18 Posts

    Re: How do I get arround: "you also cannot past a variable into a variable" Link to this post

    I want $TippOfCurrentUserForm to insert a form into the template.

    As I understand, I have to put this function into a controller, or at least the form action has to be handled by a controller. Right?
    How does TippToppMatch gets to know which controller to use?

    779 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.