Jump to:

10979 Posts in 2722 Topics by 1815 members

All other Modules

SilverStripe Forums » All other Modules » UserForms 0.2 - Extending

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 1506 Views
  • bmc38119
    Avatar
    Community Member
    45 Posts

    UserForms 0.2 - Extending Link to this post

    I have been using custom-built forms up to this point, but am interested in possibly using UserForms for client management purposes. The only drawback I have is adding dropdown fields like US states which contains 50+ items that have to be entered one-by-one. In my custom forms, i just create a class and pull in values with todropdownmap.

    Is it possible to create a UserForm and push a custom field to the userForm without breaking it? I do not care that it will not show up in the admin interface list of fields, as long as it displays in the front-end form and gets written to the submission table.

  • Willr
    Avatar
    Forum Moderator
    5497 Posts

    Re: UserForms 0.2 - Extending Link to this post

    You can easily sub class EditableFormField to provide custom functionality. Have a look at the googlemapselectionfield module for a module which provides extra options in the UserForms - http://open/browser/modules/googlemapselectionfield/trunk/code/EditableGoogleMapSelectableField.php

    So first subclass EditableFormField. You can put your sub class in its own file in your own project (eg you don't have to have it inside userforms folder for it to be loaded.

    Then you would need to create a getFormField() function in that subclass which returned a dropdown field of all the states. You can see that link I posted above for some other settings you can override in your subclass

  • edi2lopez
    Avatar
    Community Member
    6 Posts

    Re: UserForms 0.2 - Extending Link to this post

    I want to add a legend to the form, any help would appreciated. I tried:

    File: \userforms\code\editor\EditableFormLegend.php

    <?php
    /**
    Allows an editor to insert a legend into a field
    **/

    class EditableFormLegend extends EditableFormField {

       static $singular_name = 'Legend';
       
       static $plural_name = 'Legends';
          
       function getFormField() {
          $labelField = new LegendField($this->Name, $this->setLegend()->Title);
          $labelField->addExtraClass('FormLegend');
          
          return $labelField;
       }
       
    }

    Hi, I am a newby, I appreciate any hint on extending the userforms module for the legend. Thank you.

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