I have a content type which is only viewable (not editable) to a certain role. I've customised the form output completely (manually outputting each field as they display in a certain way).
However there's one field I would like this user to be able to 'edit' which is a custom 'revision comment' field I've made. I can hardcode in the form fields, except of course it won't work without the token, build id etc that Drupal generates like this:
<input type="hidden" name="form_build_id" value="<?php print render($form['#build_id']); ?>">
<input type="hidden" name="form_token" value="<?php print drupal_get_token($form['#token']); ?>">
<input type="hidden" name="form_id" value="<?php print render($form['#form_id']); ?>">
So essentially I'm wondering what workaround I could use, as $form and it's variable are obviously only generated when 'editing' the node.
In case anyone else needs to know, I hardcoded this into the template file and it works:
<form class="node-form node-project-form" action="/dashboard" method="post" id="project-node-form" accept-charset="UTF-8">
<input type="hidden" name="nid" value="<?php print $nodeid; ?>">
<input type="hidden" name="uid" value="<?php print $user->uid; ?>">
<div id="revision-comments" style="margin:0">
<label for="log-comments">Log Message</label>
<textarea id="log-comments" name="log_comments"" cols="60" rows="4" class="form-textarea"></textarea>
</div>
<input type="submit" id="edit-submit" name="op" value="Post Comment" class="form-submit">
</form>
Related
I am trying to create a form with Craft that allows users to rate entries in a specific section. The section that tracks the ratings has three fields: the ratings drop-down field, a user field, and an entry field. Here is my form right now:
<form method="post" accept-charset="UTF-8">
{{ getCsrfInput() }}
<input type="hidden" name="action" value="entries/saveEntry">
<input type="hidden" name="redirect" value="viewentry/{slug}">
<input type="hidden" name="sectionId" value="userRatings">
<input type="hidden" name="enabled" value="1">
<input type="text" id="user" name="ratings" value="{{currentUser}}" style="display:none;" readonly>
<input type="text" id="restaurant" name="restaurant" value="{{entry.id}}" style="display:none;" readonly>
<label for="ratings">Rate This Restaurant</label>
<select id="ratings" name="ratings" required>
{% for option in entry.ratings.options %}
<option value="{{ option.value }}">{{option.label}}</option>
{% endfor %}
</select>
<input class="button" type="submit" value="Rate">
I have two text boxes that are recording the current user and the Entry ID of the entry I am trying to rate (we are on the _entry.html for this entry). Before I added the "display:none" they were both showing the correct information. Then I am pulling the options for the ratings field that I set in craft and setting them as the values for the drop down here (which is working).
When I try to submit I get a craft error: "Internal Server Error Trying to get property of non-object." Any help or suggestions would be greatly appreciated!
You're missing the 'title' field ..
<input type="hidden" name="title" value="Free Registration Title">
It's a requirement
I'm trying to add payfort as a payent gateway to a new section in a website. The same code works correctly in another section. I always get "Error code: 00002 Invalid parameter format"
<form method="post" action="https://checkout.payfort.com/FortAPI/paymentPage" class="pay_form" name="form1">
<input type="hidden" name="access_code" value="access_code">
<input type="hidden" name="amount" value="1000.00">
<input type="hidden" name="command" value="PURCHASE">
<input type="hidden" name="currency" value="USD">
<input type="hidden" name="customer_email" value="user#mail.com">
<input type="hidden" name="customer_name" value="customer name">
<input type="hidden" name="language" value="en">
<input type="hidden" name="merchant_identifier" value="identifier_code">
<input type="hidden" name="merchant_reference" value="order_id">
<input type="hidden" name="return_url" value="my_return_url">
<input type="hidden" name="signature" value="form_signature">
</form>
I compared this form to another form in the other section and they are similar to each other but order id, return url and amount are different but the first form works without any issues. Any ideas?
It's because payfort only accepts whole number as amount. You need to multiply the actual amount by 100 and before sending request to payfort make sure its whole number.
I have a contact form on my site. I use formit for its FormIT validation. I want email be not more than 40 characters, be reqired and be correct email address. Message field is required too and has max length set.
Validator doesn't work correctly:
When required fields are empty, it shows error message and doesn't allow to send the form (this situation is absolutely correct)
When in email is any text (valid or not), form is sent but redirect to success page doesn't work (so it happens also when we enter more than max length)
[[!FormIt?
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
<form id="contact-form" method="post" action="[[~[[*id]]]]" enctype="application/x-www-form-urlencoded" role="form" data-toggle="validator" name="order">
<input type="text" id="name" name="name" type="name" placeholder="Name" value="[[!+fx.name]]" size=25>
<input type="text" required="required" type="email" id="email" name="email" placeholder="Email" value="[[!+fx.email]]">
[[!+fx.error.email]]
<textarea required="required" placeholder="Message" id="message" name="message">[[!+fx.message]]</textarea>
<button name="send">Send</button>
</form>
</div>
You have type attribute twice in the name input and the email input, so that might be the problem.
<input type="text" id="name" name="name" type="name">
<input type="text" required="required" type="email">
Remove type="name" and type="email" -- (leave type="text")
Also - I have only ever used a prefix of fi for Formit placeholders; do you know for sure that fx will work? Did you set that somewhere else? You say you're seeing the error message so I guess the error placeholder must be working...
Be sure to add placeholderPrefix to your FormIt call:
[[!FormIt?
&placeholderPrefix=`fx`
&hooks=`spam,email,redirect,FormItAutoResponder`
&emailTpl=`emailTplContact`
&emailSubject=`Message from site.com`
&emailTo=`myemail#gmail.com`
&validate=`email:email:required:maxLength=^40^,
message:required:maxLength=^150^`
&redirectTo=`11`
&fiarTpl=`emailAutoRespond`
&fiarSubject=`Your message is sent`
&fiarFromName=`My Site`
&fiarFrom=`myemail#gmail.com`
&fiarToField=`email`
&fiarReplyTo=`email`
]]
I am using Laravel 4 ("laravel/framework": "4.0.*").
I have my login form that uses the Form::open() helper method. The input tag for "_token" gets automatically added to the form as expected, except when a new session is created (let's say I clear my cookies), the "value" attribute is missing and there is no token value in the rendered output (View Source).
<input name="_token" type="hidden">
Only on refreshing the page, the _token value is displayed...
<input name="_token" type="hidden" value="FWFOGHSz6oUgYHFblHZ1HrPOZHQC1koF8S52sOL9">
If I however manually enter the following in the .blade file...
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>">
... I get the following in the rendered output..
<input name="_token" type="hidden"> <input type="hidden" name="_token" value="FWFOGHSz6oUgYHFblHZ1HrPOZHQC1koF8S52sOL9">
Any clues on why is the Form::open() method auto-magic stuff not working as expected?
EDIT
My Form::open() code in the .blade file is as follows:
{{
Form::open(array(
'url' => URL::full(),
'class' => 'form-vertical login-form'
))
}}
i found a strange behavior in my JSP site and hope somebody have a good advice for me:
JSP-Code:
<c:forEach items="${info.moneyList}" var="mmRoles" varStatus="uStatus" >
....
<div class="paperback" id="delete_${uStatus.index}">
<form id="deleteMoneyMarketSpread_${uStatus.index}"
action="deleteMoneyMarketSpread" method="post">
<input type="hidden" name="currency"
value="${mmRoles.currency}" />
<input type="hidden" name="loan"
value="${mmRoles.loan}" />
<input type="hidden" name="lcfspread"
value="${mmRoles.lcfspread}" />
</form>
</div>
....
</c:forEach>
I generate a form element with hidden input fields in a forEach loop. The interesting point is that (only) in the first iteration no form element will be created. When i check the HTML code with Firebug i only find the hidden input fields, but no surrounding form tag.
HTML code:
<!-- first iteration -->
<div id="delete_0" class="paperback">
<input type="hidden" value="EUR" name="currency">
<input type="hidden" value="true" name="loan">
<input type="hidden" value="123.0" name="lcfspread">
</div>
...
<!-- second iteration -->
<div id="delete_1" class="paperback">
<form id="deleteMoneyMarketSpread_1" method="post" action="deleteMoneyMarketSpread">
<input type="hidden" value="FGH" name="currency">
<input type="hidden" value="true" name="loan">
<input type="hidden" value="1.0" name="lcfspread">
</form>
</div>
Have anyone an idea why this happens?
Regards
Sascha
I still don't found a solution or a reason for this so i used a workaround an create my Form on demand with javaScript when clicking the icon. Not the best way but it works.