Html Editor Template - mvc-editor-templates

I have a editor template DisplayConfig. In DisplayConfig
#model string
<input id="#(Model)_DisplayOrder" class="DisplayTypeConfigurator" type="number" />
<input id="#(Model)" class="DisplayTypeConfigurator" type="checkbox" />
I want to call this template in my view and send string so i get different id for every textbox.
In my view
#Html.Editor("Tab_Info_Product", "DisplayConfig")
I do not want to send the value through my model.
I want the result like
<input id="Tab_Info_Product_DisplayOrder" class="DisplayTypeConfigurator" type="number" />

You should use #Html.IdForModel() to construct the ids of your <input> tags.
<input id="#Html.IdForModel()_DisplayOrder" class="DisplayTypeConfigurator" type="number" />
<input id="#Html.IdForModel()" class="DisplayTypeConfigurator" type="checkbox" />

Related

Transfer data in Thymeleaf

I have two input value like this
<input type="text" th:field="*{itemID}"placeholder="Bidding id" class="form-
control" required />
------------
<input type="hidden" th:field="*{item.id}" />
okay so how can i put the value of item.id field into itemID ?. I tried like below but it didn't work
<input type="hidden" th:field="*{itemID}" th:value="*{item.id}"
placeholder="Bidding id" class="form-control" required />
update
i tried to make it like this, but it still not work
<input type="hidden" th:name="*{itemID}" th:value="1"
placeholder="Bidding id" class="form-control" required />
Try this :
<input type="hidden" th:field="*{itemID}" th:value="${item.id}" placeholder="Bidding id" class="form-control" required />
replace the * by $ in th:value attribute

bind radiobutton in mvc

Radio Button checked item should be true based on entry.isalbum value. Below is my View code..
#foreach(abc.Models.ddt entry in entrydetails)
{
#if(entry.isAlbum=="Album")
{
<input type="radio" id="c" name="isAlbum" checked="checked" value="Album" />
<label style="margin-right:10px" for="c"><span></span>Album</label>
}
<input type="radio" id="c1" name="isAlbum" value="Movies" />
<label style="margin-right:10px" for="c1"><span></span>Movies</label>
<input type="radio" id="c2" name="isAlbum" value="Single" />
<label style="margin-right:10px" for="c2"><span></span>Single</label>
</div>
}
}
foreach loop contain value stroed in database corresponding to Album, Movies or Single.
radio button checked should be true based on entry.isAlbum vale. How can we do this, please help to us? I have three radiobutton mention in above code. Radio Button checked will be true based on entry.Isalbum vale. Please help me
Try this:
<input type="radio" id="c" name="isAlbum" #if(entry.isAlbum=="Album"){<text>checked="checked"</text>} value="Album" />
<input type="radio" id="c1" name="isAlbum" #if(entry.isAlbum=="Movies"){<text>checked="checked"</text>} value="Movies" />
<input type="radio" id="c2" name="isAlbum" #if(entry.isAlbum=="Single"){<text>checked="checked"</text>} value="Single" />

Validation of prefilled contact form fields in Magento fails

My Magento contact form has the field names prefilled, not labelled.
<input name="name" id="name" value="Name" class="required-entry input-text" type="text" />
Since the field is prefilled, the validation "required-entry" fails.
Is there a not-so-dirty way to get the validation working with prefilled values?
just try to use. Placeholder to make prefilled text
<form action="demo_form.asp">
<input type="text" name="fname" placeholder="First name"><br>
<input type="text" name="lname" placeholder="Last name"><br>
<input type="submit" value="Submit">
</form>
that would sure help you.

How can I validate that a radio button was selected using cfform built-in validation?

Say I have a simple cfform that looks like this:
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
How can I use the built-in cfform validation to ensure that at least one radio button in this group is selected? I've tried adding a validate="required" to each of the radio buttons but it doesn't work. Is there any simple way to "require" one of the buttons to be selected using cfform validation?
Do yourself a favor and don't use cfform for validation. Write your own server and client side validation, but according to the cfinput documentation if you add a required="true" attribute to each radio button ColdFusion will do the client side validation for you.
Note: The user can bypass this validation and still submit a form without checking a radio button. You need to have server side validation as well.
<cfform id="fruitForm" method="post" action="">
<cfinput type="radio" name="fruit" id="fruit_apple" value="Apple" required="true" /><label for="fruit_apple">Apple</label><br />
<cfinput type="radio" name="fruit" id="fruit_orange" value="Orange" required="true" /><label for="fruit_orange">Orange</label><br />
<cfinput type="radio" name="fruit" id="fruit_pear" value="Pear" required="true" /><label for="fruit_pear">Pear</label><br />
<cfinput type="submit" name="submitFruit" id="submitFruit" value="Submit" />
</cfform>
This works for me:
<cfform action="abc.cfm" method="post">
<cfinput type="radio" required="yes" message="pick something" name="x" value="1">radio 1
<cfinput type="radio" required="yes" message="pick something" name="x" value="">radio 2
<input type="submit" />
</cfform>
In fact, you don't even need the message attribute. It will still validate.

PayPal discount can't make it work

I'm trying to setup a discount for a the whole cart using PayPal + Codeigniter, I got this working withouth the discounts.
As far as I've read the only thing that I would need to do is set a hidden field discount_amount_cart as I saw here
Here is my form:
<form method="post" action="https://www.sandbox.paypal.com/cgi-bin/webscr" name="paypal_form">
<input type="hidden" name="rm" value="2" />
<input type="hidden" name="cmd" value="_cart" />
<input type="hidden" name="upload" value="1" />
<input type="hidden" name="currency_code" value="EUR" />
<input type="hidden" name="business" value="biz_1271300483_biz#xxxx.xx" />
<input type="hidden" name="return" value="http://xxxxxx.com/website/pt/paypal/success/8/4c237a03897e0" />
<input type="hidden" name="cancel_return" value="http://xxxxxxx.com/website/pt/paypal/cancel/8/4c237a03897e0" />
<input type="hidden" name="notify_url" value="http://xxxxxx.com/website/pt/paypal/ipn" />
<input type="hidden" name="custom" value="" />
<input type="hidden" name="no_shipping" value="1" />
<input type="hidden" name="cpp_header_image" value="http://xxxxxxxxx.com/images/logo.png" />
<input type="hidden" name="image_url" value="http://xxxxxxxxx.com/images/logo.png" />
<input type="hidden" name="invoice" value="4c237a03897e0" />
<input type="hidden" name="no_note" value="1" />
<input type="hidden" name="discount_rate_cart" value="10.00" />
<input type="hidden" name="first_name" value="Foo Bar" />
<input type="hidden" name="city" value="xxxx" />
<input type="hidden" name="address1" value="xxxxxx" />
<input type="hidden" name="zip" value="xxxxxx" />
<input type="hidden" name="lc" value="pt" />
<input type="hidden" name="email" value="xxxxx#xxx.pt" />
<input type="hidden" name="country" value="PT" />
<input type="hidden" name="item_name_1" value="Cloud Hosting WIN Business 25GB" />
<input type="hidden" name="item_number_1" value="200.00000003" />
<input type="hidden" name="amount_1" value="156" />
<input type="hidden" name="quantity_1" value="1" />
<input type="hidden" name="tax_rate_1" value="20" />
<p><input type="submit" name="pp_submit" value="Pagar" class="submit" /></p>
</form>
But when I "post" the fields the discount line won't appear, do I need to activate something in the merchant account, am I doing something wrong?
Cheers
Got it,
From the PayPal documentation:
When you use consolidated discount amounts, you should specify a consolidated tax value in tax_cart. If you do not specify a tax value and your profile specifies a tax rate, your profile tax rate is applied after the consolidated discount value is applied.
So I need to define my "global" tax amount for the cart with tax_cart.
The name of your discount input appears to be wrong:
<input type="hidden" name="discount_rate_cart" value="10.00" />
should be:
<input type="hidden" name="discount_amount_cart" value="10" />
Use discount_amount_cart to charge a
single discount amount for the entire
cart.
Use discount_amount_x to set a
discount amount associated with item x
Use discount_rate_cart to charge a
single discount percentage for the
entire cart.
discount_rate_cart - Applies to
entire cart however, this variable
will only work with the "Upload"
Method. Not the standard Add to Cart
variables.
This variable will be ignored if you
are including any individual sales tax
amount or rate in your upload method
code. This is because the sales tax
needs to be calculated after the
discount is applied to your items
therefore, the discount is applied to
the item Subtotal, not the Total.
Note, If you just using the standard
Add to Cart buttons, there no Discount
variables for the entire cart. as
they "only" apply a Discount to an
individual item.

Resources