Custom dropdown attribute on registration form - php

Follow up to Adding attributes to customer entity
My goal is to make new attribute appear on the registration form. I've added $oAttribute->setData('used_in_forms', array('customer_account_create', 'adminhtml_customer')); call which should add the new field. Point is to add new field without modifying register.phtml template directly. I will also need to hook into registration save method to handle ability to select custom answer e.g. 'Other'
Thanks in advance

the thing is that in the admin all defined customer fields are rendered automatically, but in the frontend they are added in the template (customer/form/register.phtml).
As you don't want to edit the phtml file, you could listen for example to controller_action_layout_load_before, check if the fullActionName is customer_account_create and then include a layout handle of your module which refers to a template file containing the field you want to add. See for more detailed code my last question.
Then you'll need another observer listening to Mage_Customer_AccountController's createPostAction method to process the field's value.
Hope That Helps

Related

Adding a CustomField to Infusuionsoft contact

I am trying to modify an existing integration with Infusionsoft that uses the Novak Infusionsoft PHP SDK.
The config.php file has a few custom fields defined in config.php like
//To Add Custom Fields, use the addCustomField method like below.
//Infusionsoft_Contact::addCustomField('_LeadScore');
Infusionsoft_Contact::addCustomField('_FooBar');
Infusionsoft_Contact::addCustomField('_BarFoo');
and that all works. I want to add another custom field for a text field named "Best Describes Me" in Infusionsoft and added what I thought would be the appropriate line
Infusionsoft_Contact::addCustomField('_BestDescribesMe');
But putting that line in gets an error:
[NoFieldFound]No field found: Contact._BestDescribesMe Attempted: 1 time(s).
I have been searching to see if there is anything else to be done either in the PHP toolkit or in Infusionsoft, but cannot find anything. I would actually expect that I have to do something in Infusionsoft to make the custom field externally available, but cannot find anything about that.
Any help would be greatly appreciated.
I fid find the solution. The actual field name in Infusionsoft may not be the same as what is displayed. You have to dig into the Backend Database Names for Custom Fields as described on this page:
http://help.infusionsoft.com/related-articles/backend-database-names-for-custom-fields
Go to Admin > Settings in the main navigation menu
Go to the custom field section, select a field type from the drop-down, and then click on Go.
Click on the View the field database names (for the API ) link.
The database field names will be listed in a new window.
The backend name is what needs to be put into the SDK config.php

Display custom field tabs in front end article edit page in Joomla 3.x

I have been looking for a solution to display custom field tabs in the Joomla
front article edit page.
http://www.aixeena.org/extensions/aixeena-easy-cck
Aixeena Easy CCK
I installed the plugin of aixeena, two custom field tabs: the Extra content and Extra content 2 are displayed in the backend admin article edit page, which is great. But we also need to let regular edit their article and enter values in custom fields under those two tabs. Any idea how to achieve this?
I tried a couple of other sites posting the solution of adding custom fields in article, such as Rating region described in the site:
https://docs.joomla.org/Adding_custom_fields_to_the_article_component
I was not able to make the Rating tab displayed in the front end article edit page neither.
I tried the fieldattach, it does supports custom field tab ( which is the group name of custom field), the list field type only contains static values, we have to define fieldset and field type through xml file.
Any help is greatly appreciated.
I just finished writing a couple pluginsto do this similar thing. I wrote my own plugin to add the extra fields - but it looks like the one you've already used is very similar.
I had a really hard time figuring out how to add the fields for frontend editing as well. But I finally figured it out.
First, you're going to need to copy the com_content form edit.php into a template override (/templates/your_template_name/html/com_content/form/edit.php).
In that file, add the extra fields you have. You'll need the name of the field that you put in the xml file for your plugin you already have. Add them right before/after the fields that are already in the file, that you want your fields to appear before/after. Example:
<!-- CUSTOM begin custom fields -->
<?php echo $this->form->renderField('video_url', 'attribs'); ?>
add all your fields in there - replacing 'video_url' with your own field name. The plugin you already have already saved these fields to the 'attribs' part of the article, so you can leave that there.
The plugin that I used to create the fields for the backend is a really simple one based off of this tutorial https://zunostudios.com/blog/development/203-how-to-add-custom-fields-to-articles-in-joomla
What I'd suggest is to go ahead and create that plugin too. Except in the zfields.php file, change "$app->isAdmin()" to "$app->isSite()" - make sure the xml files have the same names as your other plugin xml files, so they save to the same place, and you're done. The fields will show up on the frontend edit form now.
What I'd really recommend is to get rid of the Aixeena plugin, and just make that easy plugin using the tutorial above - it's super easy. When you make it, duplicate the "if ($app->isAdmin())" section, copy it right below it, and change "isAdmin" to "isSite" - and now you've got the entire thing, all your custom fields, both frontend and backend, all in one place. Now just do the edit.php template override, and you'll have them displayed in both the front and backend. I hope that helps - if you need I can upload more example code.

Add custom field to Magento Admin (URL field)

I'm trying to add a custom field in the Magento backend, at the Configuration -> Web section. I want to add an additional URL text space (can be in any of the sections, URL options, for example, would work well). How can I do that? I have seen other people who tried it by making a custom module, but that was for the category section. I need it at the Web section though, have not had success yet.
Thank you!
You can add an custom field to the web section. The best approach is to create a custom module for this.
In your system.xml you need to add your section to the Web section.
More information on this blog.
If you want to add attribute for product (can be text string named URL text) you can do it in catalog/attributes/manage attributes here you can create a new EAV attribute.
Next go to catalog/attributes/ manage groups/ and there you can drag/drop attribute to the correct group (will be shown in product admin page in the left list of groups)
In template you can call a attribute by call $_product->getAtributteName (if the attribute was named atributte_name) or $_product->getAnotherAttributeName (for attribute named another_attribute_name).
Always make sure if attribute is enabled for catalog / or product view you are using to make possible "get..." call from that view.
If you want it for using at URL, you can edit URL call by adding it to the end of URL as a GET parameter example:
http://www.somestore.com/?yourproductorcategoryurl&myparmforurl=<?php echo $_product->getSomeAtributteName ?>
if you using attribute type list (list of defined values, it always return an id of attribute value, not name) then you can use $_product->getAttributeText('name_of_your_attribute')
I was able to do this via the official Magento blog: http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/how_to_add_a_custom_module_for_custom_admin_config_options
Thank you for your help though!

magento custom form on product page

I'm new to Magento, and i need some conceptual guide and/or references.
I need to create custom form that will be a part of product-info page (at it's bottom) and that will collect user input (email, size, color). Only some product will have this feature/form (it's up to admin). So, goal of this form will be to email store-admin about a product that is available in stock but not in wished size and/or color. Should i customize existing Contact us form or should i create fresh custom form in new module?
Form should submit data to admin via email along with name of the product.
Ok, so first create a .phtml file under app/design/frontend/[namespace]/[theme]/template/catalog/product/send_request.phtml
then, add this .phtml file reference in catalog.xml in /app/design/frontend/[namespace]/[theme]/layout/catalog.xml
<block type="core/template" name="customer_request" template="catalog/product/send_request.phtml"/>
below the :
<label>Catalog Product View (Any)</label>
section but you should find to right section where to place ( you will find after a few try )
Finally, add your php logic into send_request.phtml file. The form contain that you implemented in send_request.phtml will available under product view page.
Sounds like you'll need a custom form. You'll need a new database table to store the data, a Model to represent the data, and a controller to post the form to at the very least. You'll probably want to add an attribute to Products which is a yes/no of whether to display the form. You'll also probably want to view the data, so you'll have to make pages in the admin site. Perhaps a grid of all answers and a page to view/edit a specific answer.
There is a free extension available. You can use this extension and customize it according to your needs. Product Questions

How should I go about capturing a custom form in Magento that is stored with the order?

I am working on a module to add a new step called Rental into the Onepage Checkout module in magento. The problem is not adding a step it is the data capture.
I want to be able to take the custom form I have created and store it with the rest of the order information so when I click view order in the backend, it shows the information in the form as a seperate box.
Preferably I want to seperate the concerns by creating a standalone module.
How would you go about doing this? What would be your personal strategy for implementing this?
Firstly, it should all depend on what data 'Rental' would be. Could it fit/be appropriately placed inside a product's custom option? Or do you need to create a custom sales attribute to store the data in?
If you want the latter, you should use Magento Module Creator by SilkSoftware to create a module to implement sales attributes.
Also: a good thread / scenario in using sales attributes: Magento: Setting a custom attribute on the sales/order_shipment model
Secondly, is capturing the form data -- this is assuming you already have a block/form created and showing on the checkout page. I highly encourage you name the fields in the following semantic:
<input type="text" name="rental[text_data]" />
<input type="text" name="rental[text_data2]" />
Where text_data and text_data2 are your desired variable names.
An order is submitted / saved finally via a Controller action called saveOrderAction in Mage_Checkout_OnepageController or whatever Controller class you are using currently for your checkout page. Don't edit the corresponding PHP Class file for this found at app/code/core/Mage/Checkout/controllers/OnepageController.php ! Since you want to separate this into another module, you should try and rewrite this controller then so that your custom Controller class inside your module that extends the aforementioned base class (Mage_Checkout_OnepageController) should be used by Magento in its stead.
A good tutorial on rewriting controllers can be found here.
You can then do either of the two options from here:
1.) you could copy the entire saveOrderAction function and create routines to save Rental data there. if you followed the naming semantic I suggested, you should be able to retrieve the form data doing so:
<?php
// app/code/local/Namespace/Module/controllers/Checkout.php
class Namespace_Module_Checkout extends Mage_Checkout_OnepageController {
public function saveOrderAction() {
.....
$this->getOnepage()->getQuote()->save();
$rental = $this->getRequest->getParam('rental');
$text_data = $rental['text_data'];
$text_data = $rental['text_data2'];
someSaveRoutine($text_data, $text_data2);
//..or someSaveRoutine($rental);
.....
}
}
2.) secondly, you could replace the above code with a custom event dispatch
$rental = $this->getRequest->getParam('rental');
Mage::dispatchEvent('checkout_onepage_controller_saveorder', array('rental'=> $rental));
then make an appropriate observer to save your custom data somewhere.
I know this isn't much, but it's a start. I will look into editing this to elaborate more in the near future.

Categories