Catalyst Framework HTML::Formhandler shows vadiate errors, when using HTML GET to Access the Site - error-handling

I have an HTML::Formhandler Form on my Catalyst Framework. The Problem is, that I get an error-message in the Form, when I load the Form-Site with an HTML GET-Requelst.
has_field 'name' => (type => 'Text', required => 1);
So if I load the Site via: localhost:3000/form no errors occurs.
But if I load the Site via localhost:3000/form?foo=bar the form says: "Field required".
Any Idea how to solve this?

By default HTML::FormHandler determines whether to validate a from by the existence of params. If you don't want to do that, you can use the 'posted' flag in the ->process statement. If you want the query parameter to provide a default to the form, you need to pass it in via an init_object: init_object => { foo => bar }.

Related

How to create a module that changes other modules' behaviors

I want to create a module for SocialEngine that changes the signup behavior by adding the option to signup using phone number and sending text message to the user's phone and letting them confirm it. I guess I need to add code in the file application/modules/User/Form/Signup.php. For example, I can add a new field as follows:
$this->AddElement('Text', 'sms', [
'class' => 'signup-name',
'label' => 'Phone Number',
'required' => true,
'validators' => [
['StringLength', true, ['min'=>11, 'max'=>11]]
]
]
);
$this->sms->getValidator('StringLength')->setMessage('Phone must be 11 digits');
However, I don't want to manually add the code. I need to add the functionality by installing the plugin and disable it by removing or disabling the plugin. How can I do that?
Do I need to mess with installation php scripts and do file operations like overwriting files or is there a better way to separate my files completely, meanwhile making them serve as a complement for a given module?

Which Magento Soap V2 method should I use for external links?

I am working on a script that imports all product information from a Magento 1.9.3.1 website.
I cant seem to find a method which allows me to get the external links data which is associated with every product.
(See screenshot)
Does anyone know which method I need to use?
A list of methods can be found here:
http://devdocs.magento.com/guides/m1x/api/soap/introduction.html#Introduction-APIMethods
I think I have used all catalog related methods but none of them seem to return the data I need.
You can use this method: http://devdocs.magento.com/guides/m1x/api/soap/catalog/catalogProduct/catalog_product.update.html
From your screenshots, these look like custom attributes. Obtain their codes from Catalog > Attributes > Manage Attributes. Then, in the catalog_product.update call, include them in additonal_attributes as an array or arrays.
Example:
'additional_attributes' => array(
array('key' => 'ready_link', 'value'=> '...'),
array('key' => 'itunes_link', 'value'=> '...'),
)

using yii rest api with default URL GET format rather than PATH format

I have a problem with a yii rest api. I configured it to work following the tutorial on the yii framework page, but after that i realised that my api works BUT NOT some big PORTIONS of my PAGE since it is based on the GET URL format rather than PATH which is required by the rest api.
So in my config/main.php i have the following setting
'urlManager' => array (
'urlFormat' => 'path',
'rules' => array (
'student/<id:\d+>/<title:.*?>' => 'student/view',
'students/<tag:.*?>' => 'student/index',
array (
'apistudent/register',
'pattern' => 'api/<model:\w+>',
'verb' => 'POST'
),
'<controller:\w+>/<action:\w+>' => '<controller>/<action>'
)
),
I also have a controller named ApiStudentController with a method called actionRegister().
So as already stated the api works normally but my page does not since i set the urlFormat to be 'path'.
The question is... how can i use the rest api but without the PATH url format and rather the default get url format (index.php?r=apistudent/register)?
I too faced the same problem in yii 1.x. I just need my API controller alone in old GET format rather than in PATH format (as i changed my websites URLs in PATH format). Finally i got it worked with a small hack in script file
$app = Yii::createWebApplication($env->configWeb); //store the app
//Change the UrlFormat for urlManager to get if a get request is given instead of a path format one.
if (isset($_GET['r'])) {
Yii::app()->urlManager->setUrlFormat('get');
}
$app->run(); //run the app
I dont know whether this solves your problem. But this can give you an idea. Happy Coding!

How to add additional variables in yii url

I'm working with Yii framework and i'm trying to implement "create pdf" button on all sorts of different url's.
My first plan was to simply add variable to url where "create pdf" button links:
'url' => Yii::app()->request->getUrl().'&pdf=true',
And it works fine on all links except when i enter directly to site like: www.example.com. In that case there is no index.php in url so button link is unusable as it looks like this:
www.example.com/&pdf=true
Is there Yii way to append variables to url or I need to do manual checks?
create your links like this :
Yii::app()->createUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
//or this if you want it with http:://
Yii::app()->createAbsoluteUrl('controllerName/actionName', array('number' => 2, 'name'=>'john'));
you can add your parameter(s) to the original parameters with the CMap::mergeArray($_GET, array('pdf' => 'true'))
and use the Yii::app()->createUrl or your Controller's createUrl function:
http://www.yiiframework.com/doc/api/1.1/CApplication#createUrl-detail
http://www.yiiframework.com/doc/api/1.1/CController#createUrl-detail

Magento API Product Create with Dropdown Attributes

I am attempting to load products using the Magento Core API product.create method.
Magento Enterprise 1.10
I am actually having great success with the exception of inserting values for dropdown attributes. It's my understanding that you simply add the attribute code and it's associated value as part of the "Params" array when you call the product.create method. I have set up the attributes as dropdowns so they can be included as filter, and I have added the options or "values" before trying to insert the products via the API. No matter what I do the value is not selected after a successful product upload.
Here are examples of my attempted syntax:
'resolution' => '3000',
'resolution' => 1,
'resolution' => array(1),
'resolution' => array('3000'),
'resolution' => 3000,
Values of YES/NO are accepted for boolean attributes, and I have no problem passing values to regular text fields. Any insight would be greatly appreciated.
Ok - so after much trial and error - it appears that you must enter the Attribute Option ID as the value when passing information to dropdown attributes.
You can use the product_attribute.options method along with the attribute ID to get these IDs - or just check your database.
Soo - if attribute 'test-dropdown' has a dropdown option of 'orange' and that option's ID is '220':
'test-dropdown' => 220,