Jump to:

1976 Posts in 1306 Topics by 607 members

Form Questions

SilverStripe Forums » Form Questions » Rendering a CompositeField in tempate via dataFieldByName()

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

Page: 1
Go to End
Author Topic: 717 Views
  • mikhail
    Avatar
    Community Member
    4 Posts

    Rendering a CompositeField in tempate via dataFieldByName() Link to this post

    Hi there, long time lurker first time poster.

    Here's my problem in a nutshell http://www.sspaste.com/paste/show/4efa627a0f228
    I have put my questions at the bottom of the snippet.

    I'm a designer by trade, so a simple problem like this is much bigger for me than most of you, I'm sure. Thank you in advance : )

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Rendering a CompositeField in tempate via dataFieldByName() Link to this post

    Ok bonus question first since that one's easy: $dataFieldByName() still works even though the fields are in a composite field, at least that's what the docs say.

    The crux of $fieldByName() (first letter is lower case) is that it's defined on the FieldSet class and not the Form class. Doing something like

    <% control Fields %>
    $fieldByName(RoomsField)
    <% end_control %>

    Should work. Hope that helps.

  • mikhail
    Avatar
    Community Member
    4 Posts

    Re: Rendering a CompositeField in tempate via dataFieldByName() Link to this post

    I tried

    <% control Fields %>
    $fieldByName(RoomsField)
    <% end_control %>

    before, but that didn't work. Your point about FieldSet/Form classes made me try a couple more things, though.
    This is what ended up working:

    $Fields.fieldByName(RoomsField)

    Which is bizzare, since it's the same thing? (or is it?)
    I gave up on this not long after I posted this question, but your reply made me revisit this and I'm happy it did. Thank you! Have a good New Years : D

  • MarcusDalgren
    Avatar
    Community Member
    288 Posts

    Re: Rendering a CompositeField in tempate via dataFieldByName() Link to this post

    Yes that's really bizzare since they are supposed to be the same thing. I'm glad it worked out!

    717 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.