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.
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 |
Thanks! That is exactly what i was looking for.
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:
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.
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>
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:
Then, in the dropdown auto populate area (around line 340), I have this:
Then, around line 564, where the options are listed, I have:
EDIT: This code is in the new_field.php file in the tools folder.
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:
EDIT: This code is in the new_field.php file in the tools folder.
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.