Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules /

Discuss all other Modules here.

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

UserForms 0.2 - Extending


Reply


3 Posts   1604 Views

Avatar
bmc38119

Community Member, 45 Posts

15 September 2009 at 9:26am

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.

Avatar
Willr

Forum Moderator, 5513 Posts

15 September 2009 at 5:36pm

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

Avatar
edi2lopez

Community Member, 6 Posts

11 October 2010 at 9:02pm

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.