Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Custom Forms In Vanilla
AudioElements
New
Comments
What do you want the form to do ? Send mail to selected users ? A plugin is the only way. The most simple form is a contact form. Look at the contact plugin and see how it is built. You can add fields or substitute fields. You can also make it so it can only be used by registered users by setting permissions.
The Contact plugin is a basic email form. You can extend it to fit your needs.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Yes... i am currently trying the contact plugin... but i am not familiar with how to change the fields... I tried before and it did not work out.
What I want to do is create a form for users to suggest categories for the forum as it is a new forum and not fully expanded...
Therefore the two fields that need to be added are... "Main Category" and "Sub Category" and then the information from the form is emailed to me.
Can you advise me on how to have these fields created please...
Very simple, you need to edit two files, the contact.php which is what you see on the page when you access the form , the html so to speak, and the innards which is what info you want them to fill out inside the default.php
This part is where you would add the fields
You would add a $Validation for each field they fill in. Just replicate the Name field for example but call it Category x or whatever .
then bellow that after the if statement and $Name add the other fields
$Category = $FormValues['YourCategory'];
Then add a field in the view contact.php
<li><?php echo $this->Form->Label('Your Category', 'YourCategory').$this->Form->TextBox('YourCategory')?></li>
Remember that to use it for your purposes you will be cloning this plugin and then calling it something else in the event you also want to use this plugin as a contact form.
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Thanks... I've been able to create the fields but the info I enter into those fields don't show up in the email when the form info is submitted.
Also, there are a few other customisations I would like to make...
I would like to remove the check box below the form as only logged in users will have access (already done) and I would like to ensure the message field is not a required on as I will be renaming it as "Additional Notes"
Also, I would like to have the logged in user's name and email populated in the "your name" and "your email" fields by defaul... but they need to be greyed out.
I know this may be much... but I would really like the help... also understanding Vanilla coding better from your help.
You can post what you did and we can say why it did not show or work.
To make the code look neat select it and then select code from the dropdown button here on the form
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
why make is so complex. just post an announcement and ask for suggestions that can be commented upon. Then other people can see ideas as well.
If you want to limit choices just use discussion polls plugin.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
This is what I've done in default.php
$Validation = new Gdn_Validation(); $Validation->ApplyRule('YourName', 'Required', 'You must enter your name.'); $Validation->ApplyRule('YourEmail', 'Email', 'You must enter your e-mail (will not be published).'); $Validation->ApplyRule('MainCategory', 'Required', 'You must enter a Main Category. It may be a new or already existing one.'); $Validation->ApplyRule('SubCategory', 'Required', 'You must enter a Sub Category. This will be a new category that is not already available.'); $Validation->ApplyRule('Message', 'Required',"You must include a Message"); $Validation->ApplyRule('Checkbox', 'Required',"You must check the box"); $FormValues = $Sender->Form->FormValues(); $Validation->Validate($FormValues); $Sender->Form->SetValidationResults($Validation->Results()); if($Sender->Form->ErrorCount() == 0){ $Name = $FormValues['YourName']; $Subject = sprintf('Contact From %s %s', $Name, date('j M Y H:i')); $Email->Subject($Subject); $Email->To( C('Garden.Email.SupportAddress', '')); $Email->From($FormValues['YourEmail']); $Email->Message($FormValues['Message']); $Option=GetIncomingValue('Form/Checkbox');
This is from contact.php
<li><?php echo $this->Form->Label('Your Name', 'YourName').$this->Form->TextBox('YourName')?></li> <li><?php echo $this->Form->Label('Your Email', 'YourEmail').$this->Form->TextBox('YourEmail')?></li> <li><?php echo $this->Form->Label('Main Category', 'MainCategory').$this->Form->TextBox('MainCategory')?></li> <li><?php echo $this->Form->Label('Sub Category', 'SubCategory').$this->Form->TextBox('SubCategory')?></li> <li><?php echo $this->Form->Label('Message', 'Message').$this->Form->TextBox('Message', array('Multiline' => True)).$this->Form->Label('Check this if You Are Not a Bot').$this->Form->Radio('Checkbox')?></li>
Gonna check out the Discussion Polls plugin now.
Ok but you also need to add it bellow $Name
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
Checked out the polls plugin... not really what I'm going for... I intend to make this form a permanent addition to the forum panel (link already created using Pockets)... and should simple and straight-forward... you can look at the forum at http://vforum.audioelements.co and check the form we are discussing here by looking for "Create Category" on the side panel.
But do please help me out!
Are they Creating a New Category or in reality just "Suggesting a New Category"
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I would just check Session and if they are logged in just grab the user name from the session and don't even present it on the form and add it as a hidden field.
likewise with email.
you'd have to experiment.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
yes... it is in reality just a suggestion form... but that doesn't look very good as a link title...
Also... if you were having trouble accessing... I just opened the form back up to the public.
I was gonna say put your money/code where your mouth is but in this case just put it here
❌ ✊ ♥. ¸. ••. ¸♥¸. ••. ¸♥ ✊ ❌
or just use $Session->User->Name and $Session->User->Email when you
$Email->From( $Session->User->Name); and remove the fields from your form
and make sure only valid sessions can fill-in form.
etc
or
pre-fill logged in user name and e-mail and only for signed-in users
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Too many categories make it hard to follow a forum. So I would prefer to have as few as possible. If there is the need for another category, your members will ask for it.
If you encourage them to suggest a new category whenever they could think of one, they will spam you with ludicrous ideas - well, at least I would do so, I guess
lol @R_J... I totally get what you're saying... and I guess it's something that I should seriously consider here. Thanks!
OK guys... been up all night working on this...
It's been over 5 years now since I last coded in php so I'm a good bit rusty and my techniques might seem a bit traditional... but here's what I worked out.
On the default.php file
on the contact.php file
It is functionally perfect to me right now but there are some kinks I still need ask you guys about... that would be about: getting the validation messages to show up... because they just don't, changing the url from /contact for the form... and adding the side panel to this page.
The page is publicly open for now... so you guys can check it out at http://vforum.audioelements.co/contact if you wish...
Thanks @vrijvlinder @peregrine and @R_J for all the help... you were all a major help thus far!
See that one for the page that looks like a Vanilla page: http://vanillaforums.org/discussion/comment/192163/#Comment_192163
Instead of ExtraPage (the plugin where I got it from) use your own plugin name. And instead of this
$Sender->Render('extrapage', '', 'plugins/ExtraPage');
use your contact.phpDo you have something like that in your contact.php?
You have to echo the forms errors.