Displaying Magento Custom Payment Methods Form (Extension Development) - magento

I was unable to display the payment form for "My Custom Gateway" when the method is selected.
I have created the form.phtml template and it is loaded correctly. I can see the tag is loaded properly. Moreover it is visible even when I have not choose that method yet. Thus I have to hide the form until the the gateway is selected, so I have the following form.phtml:
<?php
// PHP Code
?>
<ul class="form-list" id="mygateway_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
<li>
<div class="input-box">
This will be the Forms
</div>
</li>
</ul>
In my Model, I'm extending Mage_Payment_Model_Method_Abstract instead of CC
I couldn't find any reference in the Magento source code that take care this trivial logic: hiding and showing payment form.
So, in magento, how to make my form visible when the user click on that particular payment methods?
Reference List
Create Payment Method Module

Looking at the payment/methods.phtml, the input.onclick will trigger a payment.switchMethod($_code).
Going deeper to the varien/payment.js:switchMethod function, the naming convention is important for the form. the id has to begin with payment_form_<paymentmethod>
Thus, I've made a mistake in the forms.phtml. It should be:
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
Now it is correctly display the form.

Related

What are the methods to pass Springboot/Thyleaf objects to Modal forms?

I'm confused. I've thought it's possible to pass SpringBoot/Thymeleaf objects from the html page to the Modal form. I've come across many examples using ajax to pull data from the REST endpoint instead.
Is using ajax to pull in objects into Modals, the only method?
Thymeleaf is a server side templating language... the concept of a modal form usually means showing/hiding a window opens and closes on the client side (meaning JavaScript that runs when a user clicks a link or a button ). If you don't want to use an API to pull that data (which I think makes the most sense), then you have to create a hidden modal for every row on your page. For example:
<div th:each="item, i: ${items}">
<a href="#"
onClick="openModal(this.getAttribute('data-modal'))"
th:data-modal="|#modal${i.index}|">
Edit modal #<span th:text="${i.index}" />
</a>
<div th:id="|modal${i.index}|" style="display: none;">
<p>I am a modal form for element <span th:text="${i.index}" />!</p>
<input type="text" th:value="${item.value}" />
</div>
</div>
You can see how this works... creating a hidden div/modal form for every row (so you don't have to call an API to get the form values), but it comes with a lot of extra HTML.

Is it recommended to make general partials for modals, drop-downs etc in Laravel Blade?

I am looking for a very general way to include bootstrap components in my blade view. For example let's say I need a drop down in my view, should I make a partial called dropdown.blade.php with code as follows:
<div class="dropdown">
<a href="#" class="dropdown-toggle" type="button" data-toggle="dropdown">
<span class="glyphicon glyphicon-chevron-down"></span></a>
<ul class="dropdown-menu">
#foreach ($options as $option)
<li>{{$option["name"]}}</li>
#endforeach
</ul>
</div>
and use it in my view in the following way:
#include('partials.dropdown',
array("options"=>array(
["href"=>"#", "name"=>"Profile"],
["href"=>"#", "name"=>"Report"],
)))
Even we can make it more generic by adding options for button name etc. Is it a good or preferable way to do it or should we use copy-paste method from bootstrap website to our views every time? Is there any package that is doing this sort of work? Can we make it in more elegant way?
This seems like a good idea if you are going to re-use the component a lot. I think the more elegant way to do it would be to create custom blade directives:
https://laravel.com/docs/master/blade#extending-blade
Then you could do, for instance:
#dropdown($options, 'btn-primary')
I would also provide an argument for a custom element ID or name, so you can reference it elsewhere on the page as needed.
This gets a little more complex with things like modals. I think you'd want to register multiple blade directives so you could do something like
#startmodal
#modaltitle('Title')
#startmodalbody
Some body content
#endmodalbody
#endmodal

How to remove summery box in magento review form

I have remove the summery box magento product review form. but when i submit the review it still says "Review summary can't be empty". i thought there is server side validation in magento.
anyone help me how can i remove the validation for summery box in product review from
Magento doesn't provide this as a option. But, you can go into template template/review/form.phtml and hide displaying summary field and set some value for it:
<li style="display: none">
<label for="summary_field" class="required"><em>*</em><?php echo $this->__('Summary of Your Review') ?></label>
<div class="input-box">
<input type="text" name="title" id="summary_field" class="input-text required-entry" value="SOMEVALUE" />
</div>
</li>
Magento engine uses client site and server site validation for processing any kinds of form. If you want remove this field completely you need to overwrite core functionality. The following steps should help you.
To stop server site validation
copy the file app/code/core/Mage/Review/Model/Review.php to app/code/local/Mage/Review/Model/Review.php
search the validate method in the copied file(around line number 118)
see the line $errors[] = Mage::helper('review')->__('Review summary can\'t be empty');
and comment this line
To stop client site validation
go to the file template/review/form.phtml in your theme folder.
and remove/hide displaying summary field

Magento product overview and detail separated view

I want to handle the product overivew separataly to the product detail view. I want to add additional text right behind the price in the product deatil view.
I tried to edit the view.phtml in path app/design/frontend/mytheme/default/template/catalog/product/view.phtml, refreshed caches and so on, but nothing changed.
In catalog.xml view.phtml will be load. So its seems correct.
But even when I try to echo "test" it doesnt show anything.
<?php if ($_product->getShortDescription()):?>
<div class="short-description">
<div class="std"><h2><?php echo $this->__('Details:') ?></h2>
</div>
</div>
<?php echo "test";
endif;?>
Do you have any hint?
Regards
Matt
You should enable template path hints in the backend to check which template file is used to render product page. Make sure that the cache is also disabled.

Joomla Registration form Fields Ordering

How do I order the fields on my joomla registration form?
As you can see, the captcha must be at the bottom:
http://www.celinasoft.com/index.php/component/users/?view=registration
First of all you will need to create your Registration view template override (to keep it Joomla update proof). To do so, create folder /templates/YOUT_TEMPLATE/html/com_users/registration and copy /components/com_users/views/registration/tmpl/default.php file there.
Then you will need to modify the code itself, open /templates/YOUT_TEMPLATE/html/com_users/registration/default.php file, you will see, that by default Joomla takes ALL fields from registration.xml file and just loops them through foreach cycle, this code:
<?php foreach ($this->form->getFieldsets() as $fieldset): ?>
...
...
<?php endforeach; ?>
You need to replace this cycle by your manual fields output like this:
<div class="control-group">
<div class="control-label"><?php echo $this->form->getLabel('email'); ?></div>
<div class="controls"><?php echo $this->form->getInput('email'); ?></div>
</div>
...
...
And output all desired registration fields like that, in order you prefer. Warning: don't forget that almost all of that fields are required for registration and cannot be missed.
You can find all field names in XML file components/com_users/models/forms/registration.xml
Please note that this is only sample code, to understand the logics. It haven't been tested live. So if errors occur - please let me know and we'll fix it :)
If anyone have a better/easier solution - I'd be happy to hear it.

Resources