Add a custom Field

Permalink Browser Info Environment
Love this tool!

I'm a developer and need to customize it a bit farther by adding some new fields for my client. Can you give me a quick rundown on what i need to do to accomplish this.

An example of a field i am going to add is a "Users" field that grabs all the users on of the system and puts them in a drop down. I'm just trying to make it easy on my client to add this to their forms.

Type: Discussion
Status: New
clevyr
View Replies:
jgarcia replied on at Permalink Reply
jgarcia
Hmm...good question. Adding custom fields is not something that I had in mind when designing the add-on, but that doesn't mean it's not possible!

It would be kind of tricky to give a step-by-step, since there isn't really a process for this, but I can at least give you a general idea of where to look, and then maybe try to answer any specific questions you might have.

For your example, there's probably X main places you'll need to look in order to create the field:

1. tools/new_field.php. This is the front-end UI dialog box.
2. models/field.php. You'd need to modify the render() function, as well as add a functions for renderUserField() (or whatever you end up calling it).
3. single_pages/dashboard/sixeightforms/forms.php. You'd need to add some code in here to give the option of selecting a "User" field.

If I'm remembering correctly, those are the only files you'll need to modify. Hopefully that gives you somewhere to start at least. Let me know if you have any other specific questions.
clevyr replied on at Permalink Reply
clevyr
Thanks! That is exactly what i was looking for.
FatTony1952 replied on at Permalink Reply
FatTony1952
Couldn't you just call the users into the dropdown options in the form editor? Sort of like it does with States, Days, etc.?

Something sort of like:

case 'users':
         $('#numbers_form').hide();
         $('#options').val("<?php  echo $group; ?>");
         break;


in the new_field.php file?

I'm not sure how you would call the users into the page, but you would have to put the 'users' into your option list as well.

<select id="auto-populate-option" onchange="populate_options(this.value);">
                  <option value=""></option>
                  <option value="users"><?php  echo t('Users'); ?></option>
                        <option value="days"><?php  echo t('Days of the Week'); ?></option>
                  <option value="months"><?php  echo t('Months'); ?></option>
                  <option value="states"><?php  echo t('U.S. States'); ?></option>
                  <option value="countries"><?php  echo t('Countries'); ?></option>
                  <option value="numbers"><?php  echo t('Numbers'); ?></option>
               </select>
FatTony1952 replied on at Permalink Reply
FatTony1952
Out of curiosity I tried to take a crack at my method and have been unsuccessful so far. But, I feel like I'm on the verge of a breakthrough at any moment!

I think my mistake is where I'm calling the userList into the page. I'm using:

Loader::model('user_list');
$userList = new UserList(); 
$userList->filterByGroupID('4');


Then, in the dropdown auto populate area (around line 340), I have this:

function populate_options(option_set) {
   switch(option_set) {
      case 'users':
         $('#numbers_form').hide();
         $('#options').val("<?php  echo $userList; ?>");
         break;


Then, around line 564, where the options are listed, I have:

<div class="ccm-note">
               <?php  echo t('Auto-populate:'); ?>
               <select id="auto-populate-option" onchange="populate_options(this.value);">
                  <option value=""></option>
                  <option value="users"><?php  echo t('Users'); ?></option>


EDIT: This code is in the new_field.php file in the tools folder.

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.