Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Class:FormAction $extraClass problem

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1498 Views
  • camspiers
    Avatar
    Community Member
    5 Posts

    Class:FormAction $extraClass problem Link to this post

    Hi,

    I'm using version 2.2.2, and I have run into a problem setting a custom class(HTML) using the FormAction Class. This Class gives you the option (using the Class constructor) to set a extra class to output in the generated HTML.

    This is implemented by the function Field().

    function Field() {
          $titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
          return "<input class=\"action " . $this->extraClass(). "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
       }

    When I try to use this existing code my extra class is not added, so i have changed it to:

    function Field() {
          $titleAttr = $this->description ? "title=\"" . Convert::raw2att($this->description) . "\"" : '';
          return "<input class=\"action " . $this->extraClass . "\" id=\"" . $this->id() . "\" type=\"submit\" name=\"{$this->name}\" value=\"" . $this->attrTitle() . "\" $titleAttr />\n";
       }

    And voila.
    Hope this helps someone.
    Sorry if the code doesn't format properly, I have not used this forum for submitting code.

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