In PyroCMS (Version 2.2.3) there is a Contact plugin.
How is one supposed to add a class to one of the text inputs ?
To contact us please fill out the form below.
{{ contact:form name="text|required" email="text|required|valid_email" subject="dropdown|Support|Sales|Feedback|Other" message="textarea" }}
Name:{{ name }}
Email:{{ email }}
Subject:{{ subject }}
Message:{{ message }}
{{ /contact:form }}
To Something like this
To contact us please fill out the form below.
{{ contact:form name="text|required" email="text|required|valid_email" subject="dropdown|Support|Sales|Feedback|Other" message="textarea" }}
Name:{{ name }}
Email:{{ email }}
Subject:{{ subject }}
Message:{{ message: class='css_message' }}
{{ /contact:form }}
I had this problem too. When the form get's printed out onto your page, each field is given an ID prefixed with contact_ and a class name that matches the field name. The form itself has a default class of "contact-form". Here's mine:
This setup...
{{contact:form
name="text|required"
phone="text|required"
email="text|required|valid_email"
message="textarea|required"
attachment="file|doc|pdf|zip|docx" max-size="10000"
template="recruitment"
button="Enquire Now"}}
<div><label for="name">Full Name:</label>{{name}}</div>
<div><label for="phone">Phone:</label>{{phone}}</div>
<div><label for="email">E-mail Address:</label>{{email}}</div>
<div><label for="message">Message:</label>{{message}}</div>
<div><label for="attachment">Attach your CV (Formats accepted: PDF, DOC, DOCX, ZIP): </label>{{attachment}}</div>
{{/contact:form}}
Will generate this form...
<form action="http://www.companysite.dev/recruitment" class="contact-form" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<input type="text" name="d0ntf1llth1s1n" value=" " class="default-form" style="display:none" />
<div>
<label for="name">Full Name:</label><input type="text" name="name" value="" id="contact_name" class="name" />
</div>
<div>
<label for="phone">Phone:</label><input type="text" name="phone" value="" id="contact_phone" class="phone" />
</div>
<div>
<label for="email">E-mail Address:</label><input type="text" name="email" value="" id="contact_email" class="email" />
</div>
<div>
<label for="message">Message:</label><textarea name="message" cols="40" rows="10" id="contact_message" class="message"></textarea>
</div>
<div>
<label for="attachment">Attach your CV (Formats accepted: PDF, DOC, DOCX, ZIP):</label><input type="file" name="attachment" value="" id="contact_attachment" class="attachment" />
</div>
</form>
You can then style your message field using any of following CSS methods
.contact-form .message {
// Styles go here
}
.message {
// Styles go here
}
.contact-form #contact_message {
// Styles go here
}
#contact_message {
// Styles go here
}
Hope that helps!
Related
So i'm trying to save date from this form to my database using laravel but when I test it using print-r
it shows that the form doesn't send anything and I couldn't figure where the problem is ?
View
<form action="{{ route('auctioneer.save') }}" method="POST">
#csrf
<fieldset>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<fieldset>
<label class="control-label" for="readOnlyInput">Name</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->name }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<fieldset>
<label class="control-label" for="readOnlyInput">email</label>
<input class="form-control" id="readOnlyInput" type="text" value="{{ Auth::user()->email }}" readonly="" style="width: 100%">
</fieldset>
</div>
<div class="form-group" style="width: 35%; position: absolute; margin-left: 4%">
<label for="entreprisepos">Position dans l'entreprise</label>
<input type="text" class="form-control" required id="entreprisePos" aria-describedby="aucti" placeholder="Commercial ...">
</div>
<div class="form-group" style="width: 35%;margin-left: 60%">
<label for="entrepriseNom">Nom du l'entreprise</label>
<input type="text" class="form-control" required id="entrepriseNom" aria-describedby="aucti" placeholder="Make it Happen ...">
</div>
<div class="form-check">
<label class="form-check-label">
<input class="form-check-input" id="termsChkbx " type="checkbox" value="" checked="" onchange="isChecked(this, 'sub1')">
I Agree on Terms and Conditions
</label>
</div>
<div class="form-group text-center">
<button type="submit" class="ps-btn" id="sub1" style="width: 20%;" value="Submit">
Submit Form
</button>
</div>
</fieldset>
</form>
Route
Route::post('/submitauct','AuctioneerController#save')->name('auctioneer.save');
Controller
public function save( Request $req){
print_r($req->input());
}
Display
Array ( [_token] => xNY3q1BvlxuT3zylwhtONx0Xv13qVPUhrrga8omo )
you miss the name attribute in tag your data is pass in request but doesnot get any name so you didint see the data
always remamber id is usefull when you work with frontend like js/jquery/css but when you want to work in backend you have to passs name attribute.
next mistake is always use not button when you want to submit form in laravel.
use button when you want to submit form using ajax or axios its good.
hint:in dd() token is print becuase when you use #csrf you get this.
it has by default name property so it shows
pleas if this is helpful vote up..................................................
If you want to send data from HTML form, you need use input attribute name.
<input name="foo" value="bar">
Then you can get the value in Laravel :
request()->input('foo');
I'm trying to duplicate 4 input text. For example I want to duplicate 'Produk Simpanan Saham', then only 4 input on 'Produk Simpanan Saham' div will be duplicated. I already tried a few methods using jQuery but it seem doesn't work.
<form action="" method="post" class="form-horizontal">
<br><br>
<div class="form-group">
Upload File :
<input type="file" name="file">
</div>
<div class="saham">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Saham</center>
</h3>
</div>
<label for="kp_produk">Kode Produk :</label>
<input type="text" name="kp_produk" class="form-control">
<br>
<label for="produk_saham">Produk :</label>
<input type="text" name="produk_saham" class="form-control">
<br>
<label for="bunga_saham">Bunga :</label>
<input type="text" name="bunga_saham" class="form-control">
<br>
<label for="ket_saham">Keterangan :</label>
<input type="text" name="ket_saham" class="form-control">
</div>
<div class="harian">
<div class="w3-container w3-black">
<h3>
<center>Produk Simpanan Harian</center>
</h3>
</div>
<label for="kp_harian">Kode Produk :</label>
<input type="text" name="kp_harian" class="form-control">
<br>
<label for="produk_harian">Produk :</label>
<input type="text" name="produk_harian" class="form-control">
<br>
<label for="bunga_harian">Bunga :</label>
<input type="text" name="bunga_harian" class="form-control">
<br>
<label for="ket_harian">Keterangan :</label>
<input type="text" name="ket_harian" class="form-control">
</div>
you mush have blueprint of field first like
var blueprint= '<div class="saham">'+
'<div class="w3-container w3-black">'+
'<h3>'+
'<center>Produk Simpanan Saham</center>'+
'</h3>'+
'</div>'+
'<label for="kp_produk">Kode Produk :</label>'+
'<input type="text" name="kp_produk[]" class="form-control">'+
'<br>'+
......
used [] for all name field to get array request when you send form to server
example :
'<input type="text" name="kp_produk[]" class="form-control">'+
and make button add like (jquery) example
<button onclick="$('form').append(blueprint)">add</button>
just use
var dom=$($('.saham')[0]).clone();
//copy dom
$('.form-horizontal').html(dom):
//paste dom
dont forget to add [] on name tag dom input to set data send to array, because if you not set. data with key kp_produk value is last tag name with name kp_produk
if you use [] (kp_product[]) data will set to array
kp_product=['anu1',anu2];
I have a basic HTML/PHP web form. Everything works fine when I fill out all fields, except I want to make the file upload optional, not required. I have taken "required" off of the form html for the upload. I checked my handler.php and it does not say that field is required. I checked the formhandler.php and it says that attachments are null. I have looked through similar questions, but any of the more complex solutions I am probably implementing incorrectly. I've expended my knowledge of php looking for a solution. What am I missing?
Here is the html of the form:
<div class="row pb6">
<div class="col-md-6 offset-md-3">
<form role="form" method="post" id="reused_form" enctype="multipart/form-data" >
<div class="form-group">
<label for="name"> Name:</label>
<input type="text" class="form-control" id="name" name="name" required maxlength="50">
</div>
<div class="form-group">
<label for="email"> Email:</label>
<input type="email" class="form-control" id="email" name="email" required maxlength="50">
</div>
<div class="form-group">
<label for="tel"> Phone: </label>
<input type="tel" class="form-control" id="tel" name="tel" maxlength="50">
</div>
<div class="form-group">
<label for="name"> Message:</label>
<textarea class="form-control" type="textarea" name="message" id="message" placeholder="We want to hear all about your performance! Also, please include the date you need the music." maxlength="6000" rows="7"></textarea>
</div>
<div class="form-group">
<label for="file">File Upload (optional)</label>
<input type="file" class="form-control" id="image" name="image">
</div>
<button type="submit" class="btn btn-lg btn-success pull-right" id="btnContactUs">Post It! →</button>
</form>
<div id="success_message" style="width:100%; height:100%; display:none; "> <h3>Sent your message successfully!</h3> </div>
<div id="error_message" style="width:100%; height:100%; display:none; "><h3>Error</h3>We are very sorry. There was an error sending your form. Email us and we will send you a free demo.</div>
</div>
</div>
</div>
And here is the handler.php:
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
/*
Tested working with PHP5.4 and above (including PHP 7 )
*/
require_once './vendor/autoload.php';
use FormGuide\Handlx\FormHandler;
$pp = new FormHandler();
$validator = $pp->getValidator();
$validator->fields(['name','email','tel'])->areRequired()->maxLength(50);
$validator->field('email')->isEmail();
$validator->field('message')->maxLength(6000);
if($_FILES['image']){ $pp->attachFiles(['image']); }
$pp->sendEmailTo('email'); //
echo $pp->process($_POST);
after code edit:
1)Chrome and Firefox will send form, Safari will not.
2)All browsers show a perpetual "Sending" message, and do not show a success or failure message for the form.
3) Forms send WITH attachments will not send the form with attachment to email, only the form alone.
You are trying to attach the image whether it exists or not with $pp->attachFiles(['image']);. You should first check if it does indeed exists and only attach it if it does like so:
if($_FILES['image']){
$pp->attachFiles(['image']);
}
I couldn't find an answer to my scenario, at least couldn't manage to implement one properly. I'm using Tsoha-Bootstrap and Twig and have a form that submits information about a clip. What I'm trying to do is:
Separate the resolution field into two boxes with an x in between the fields.
After the height and width of the resolution is filled in, I need those to be combined into one name property (name="resolution").
Here's what the form looks like with the code I have: http://gyazo.com/1051cc2c37dc413a31f6ca6b60111969
As you can see, the res is not aligning as intended and not quite sure how to make the combination method happen.
Here's my form:
{% extends "base.html" %}
{% block content %}
<h1>Upload a fresh clip</h1>
{% if errors %}
<div class="alert alert-danger">
<ul>
{% for error in errors %}
<li>{{error}}</li>
{% endfor %}
</ul>
</div>
{% endif %}
<script language="javascript">
function combineResolution(){
document.getElementsByName("resolution").value = document.getElementById("res1").value + " x " + document.getElementById("res2").value;
}
</script>
<form method="post" action="{{base_path}}/clipList">
<div class="form-group">
<label>Title</label>
<input type="text" value="" name="title" value="<?php echo htmlspecialchars($_GET['title']); ?>" class="form-control" />
</div>
<div class="form-group">
<label>Game</label>
<input type="text" value="" name="game" value="<?php echo htmlspecialchars($_GET['game']); ?>" class="form-control" />
</div>
<div class="form-group">
<label style="float:left;display:inline-block">Resolution</label> <br>
<input id="res1" type="text" value="" name="res1" value="<?php echo htmlspecialchars($_GET['resolution']); ?>" class="form-control" style="width: 60px;float:left;display:inline-block"/>
<p style="float:left"> <strong>X</strong> </p>
<input id="res2" type="text" value="" name="res2" value="<?php echo htmlspecialchars($_GET['resolution']); ?>" class="form-control" style="width: 60px;float:left;display:inline-block"/>
</div>
<br>
<div class="form-group">
<label>FPS</label>
<input type="text" value="" name="fps" value="<?php echo htmlspecialchars($_GET['fps']); ?>" class="form-control" />
</div>
<div class="form-group">
<label>Upload date</label><br> <!-- Try to auto-add this without a field somehow. -->
<input type="date" value="" name="added" value="<?php echo htmlspecialchars($_GET['added']); ?>" />
</div>
<div class="form-group">
<label>Description</label>
<textarea value="" name="description" value="<?php echo htmlspecialchars($_GET['description']); ?>" class="form-control"></textarea>
</div>
<div class="form-group">
<button type="submit" class="btn btn-primary" action=combineResolution()>Save Changes</button>
</div>
</form>
{% endblock %}
The properties are passed onto a store method that puts the info into a table using the name properties of each field. (Which is why I figured using getElementsByName() would work.)
You can make a hidden input with name="resolution".
Add a jQuery trigger on inputs to catch blur action.
After a trigger fire you update the value in that hidden input.
This is how the registration form of FOSUserBundle looks like:
<form action="/Symfony/web/signup/" method="POST" class="fos_user_registration_register">
<div id="fos_user_registration_form">
<input type="hidden" id="fos_user_registration_form__token" name="fos_user_registration_form[_token]" value="c248f3ef17b082803ae9948c03d137c380f0dc24"/>
<div>
<label for="fos_user_registration_form_username">Username:</label><input type="text" id="fos_user_registration_form_username" name="fos_user_registration_form[username]" required="required" maxlength="255" pattern=".{2,255}"/>
</div>
<div>
<label for="fos_user_registration_form_email">Email:</label><input type="email" id="fos_user_registration_form_email" name="fos_user_registration_form[email]" required="required"/>
</div>
<div>
<label for="fos_user_registration_form_plainPassword_first">Password:</label><input type="password" id="fos_user_registration_form_plainPassword_first" name="fos_user_registration_form[plainPassword][first]" required="required"/>
</div>
<div>
<label for="fos_user_registration_form_plainPassword_second">Verification:</label><input type="password" id="fos_user_registration_form_plainPassword_second" name="fos_user_registration_form[plainPassword][second]" required="required"/>
</div>
</div>
<div>
<input type="submit" value="Register"/>
</div>
So, as you can see,
<input type="email" id="fos_user_registration_form_email" name="fos_user_registration_form[email]"
MAIN QUESTION: How can I change the id to something like id="email" and also the name to something like name="email"? And it has to work, obviously.
Here you can see: https://github.com/FriendsOfSymfony/FOSUserBundle/blob/master/Resources/views/Registration/register_content.html.twig {{ form_widget(form) }}, but I can't trace this to where it goes. I also presume the RegistrationFormHandler would have to be edited to support these parameters.
Alter buildForm function in RegistrationFormType class:
# FOSUserBundle/Form/Type/RegistrationFormType.php
class RegistrationController extends ContainerAware
{
// ...
public function getName()
{
return 'fos_user_registration';
}
}
Change fos_user_registration to whatever you want.