How to call controller method from another controller?Exclude a specific categoryhow to override a Core...
How to access internet and run apt-get through a middle server?
Does it take energy to move something in a circle?
Not a Long-Winded Riddle
Does an Eldritch Knight's Weapon Bond protect him from losing his weapon to a Telekinesis spell?
Calculate of total length of edges in Voronoi diagram
Microtypography protrusion with Polish quotation marks
Can we "borrow" our answers to populate our own websites?
Prioritising polygons in QGIS
Why zero tolerance on nudity in space?
What is the difference between "...", '...', $'...', and $"..." quotes?
Does diversity provide anything that meritocracy does not?
What game did these black and yellow dice come from?
What is the industry term for house wiring diagrams?
Buying a "Used" Router
What to do with threats of blacklisting?
Does the US government have any planning in place to ensure there's no shortages of food, fuel, steel and other commodities?
Do authors have to be politically correct in article-writing?
If angels and devils are the same species, why would their mortal offspring appear physically different?
Is a new boolean field better than null reference when a value can be meaningfully absent?
Why do all the books in Game of Thrones library have their covers facing the back of the shelf?
Why do we have to make "peinlich" start with a capital letter and also end with -s in this sentence?
What makes papers publishable in top-tier journals?
Potential client has a problematic employee I can't work with
Coworker asking me to not bring cakes due to self control issue. What should I do?
How to call controller method from another controller?
Exclude a specific categoryhow to override a Core Customer Model in a local module in magento 1.9.2Shopping cart is empty after cancel the payment in magento-1.9.1.1how to reset password for 15000 user and send it to the email id in magento 1.9Magento1 createBlock method returns “bool(false)” in livehostHow to use non class file and call Actions magento1.9?Error start SessionGet Shipment Id while creating Shipment in Magento 1.9How to resolve Call to a member function getTelephone() for guest user login magento 1.9.1.0?Magento 1.9.2.4 Custom Captcha not displaying
Created a model in which the form validation on the beck
public function validation_form()
{
$error = false;
if (!Zend_Validate::is($name, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Name is required');
}
if (!Zend_Validate::is($message, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Message is required');
}
if (!Zend_Validate::is($subject, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Subject is required');
}
if (!Zend_Validate::is($email, 'EmailAddress')) {
$error = Mage::getSingleton('core/session')->addError('Email is required');
}
if ($error) {
throw new Exception();
}
}
And there is a method in the controller that adds data to the database.
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {
$name = $this->getRequest()->getPost('name');
$email = (string)$this->getRequest()->getPost('email');
$phone = $this->getRequest()->getPost('phone');
$user_agent = Mage::helper('core/http')->getHttpUserAgent();
$remote_ip = Mage::helper('core/http')->getRemoteAddr();
$subject = $this->getRequest()->getPost('subject');
$other_subject = $this->getRequest()->getPost('other');
$message = $this->getRequest()->getPost('message');
$created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
etc...
How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.
Path to the controller mymodul/feedback/controllers/IndexController.php
Path to the validation mymodul/feedback/model/Validation.php
magento-1.9
New contributor
add a comment |
Created a model in which the form validation on the beck
public function validation_form()
{
$error = false;
if (!Zend_Validate::is($name, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Name is required');
}
if (!Zend_Validate::is($message, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Message is required');
}
if (!Zend_Validate::is($subject, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Subject is required');
}
if (!Zend_Validate::is($email, 'EmailAddress')) {
$error = Mage::getSingleton('core/session')->addError('Email is required');
}
if ($error) {
throw new Exception();
}
}
And there is a method in the controller that adds data to the database.
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {
$name = $this->getRequest()->getPost('name');
$email = (string)$this->getRequest()->getPost('email');
$phone = $this->getRequest()->getPost('phone');
$user_agent = Mage::helper('core/http')->getHttpUserAgent();
$remote_ip = Mage::helper('core/http')->getRemoteAddr();
$subject = $this->getRequest()->getPost('subject');
$other_subject = $this->getRequest()->getPost('other');
$message = $this->getRequest()->getPost('message');
$created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
etc...
How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.
Path to the controller mymodul/feedback/controllers/IndexController.php
Path to the validation mymodul/feedback/model/Validation.php
magento-1.9
New contributor
add a comment |
Created a model in which the form validation on the beck
public function validation_form()
{
$error = false;
if (!Zend_Validate::is($name, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Name is required');
}
if (!Zend_Validate::is($message, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Message is required');
}
if (!Zend_Validate::is($subject, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Subject is required');
}
if (!Zend_Validate::is($email, 'EmailAddress')) {
$error = Mage::getSingleton('core/session')->addError('Email is required');
}
if ($error) {
throw new Exception();
}
}
And there is a method in the controller that adds data to the database.
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {
$name = $this->getRequest()->getPost('name');
$email = (string)$this->getRequest()->getPost('email');
$phone = $this->getRequest()->getPost('phone');
$user_agent = Mage::helper('core/http')->getHttpUserAgent();
$remote_ip = Mage::helper('core/http')->getRemoteAddr();
$subject = $this->getRequest()->getPost('subject');
$other_subject = $this->getRequest()->getPost('other');
$message = $this->getRequest()->getPost('message');
$created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
etc...
How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.
Path to the controller mymodul/feedback/controllers/IndexController.php
Path to the validation mymodul/feedback/model/Validation.php
magento-1.9
New contributor
Created a model in which the form validation on the beck
public function validation_form()
{
$error = false;
if (!Zend_Validate::is($name, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Name is required');
}
if (!Zend_Validate::is($message, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Message is required');
}
if (!Zend_Validate::is($subject, 'NotEmpty')) {
$error = Mage::getSingleton('core/session')->addError('Subject is required');
}
if (!Zend_Validate::is($email, 'EmailAddress')) {
$error = Mage::getSingleton('core/session')->addError('Email is required');
}
if ($error) {
throw new Exception();
}
}
And there is a method in the controller that adds data to the database.
public function postAction()
{
$post = $this->getRequest()->getPost();
if ($post) {
$name = $this->getRequest()->getPost('name');
$email = (string)$this->getRequest()->getPost('email');
$phone = $this->getRequest()->getPost('phone');
$user_agent = Mage::helper('core/http')->getHttpUserAgent();
$remote_ip = Mage::helper('core/http')->getRemoteAddr();
$subject = $this->getRequest()->getPost('subject');
$other_subject = $this->getRequest()->getPost('other');
$message = $this->getRequest()->getPost('message');
$created_at = Mage::getModel('core/date')->date('Y-m-d H:i:s');
etc...
How to connect function postAction() to validation so that the variables "$name, $email, etc..." are available in the validation model.
Path to the controller mymodul/feedback/controllers/IndexController.php
Path to the validation mymodul/feedback/model/Validation.php
magento-1.9
magento-1.9
New contributor
New contributor
edited 4 hours ago
Рома Лытарь
New contributor
asked 21 hours ago
Рома ЛытарьРома Лытарь
325
325
New contributor
New contributor
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I see several issues here:
your method
validation_form()
does not take any parameters. It should be something likepublic function validation_form($name, $message, $subject, $email)
. Else, the method does not have access to any of the values frompostAction()
.I don't knot if you can throw an
Exception()
with an empty message, and I'm not sure if thevalidate_form()
method will work as expected, but you can try and open another question if new errors occur :)From your
postAction()
, call the method like this:
Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);
...assuming you defined your model namespace in your config.xml
file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263333%2fhow-to-call-controller-method-from-another-controller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I see several issues here:
your method
validation_form()
does not take any parameters. It should be something likepublic function validation_form($name, $message, $subject, $email)
. Else, the method does not have access to any of the values frompostAction()
.I don't knot if you can throw an
Exception()
with an empty message, and I'm not sure if thevalidate_form()
method will work as expected, but you can try and open another question if new errors occur :)From your
postAction()
, call the method like this:
Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);
...assuming you defined your model namespace in your config.xml
file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
add a comment |
I see several issues here:
your method
validation_form()
does not take any parameters. It should be something likepublic function validation_form($name, $message, $subject, $email)
. Else, the method does not have access to any of the values frompostAction()
.I don't knot if you can throw an
Exception()
with an empty message, and I'm not sure if thevalidate_form()
method will work as expected, but you can try and open another question if new errors occur :)From your
postAction()
, call the method like this:
Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);
...assuming you defined your model namespace in your config.xml
file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
add a comment |
I see several issues here:
your method
validation_form()
does not take any parameters. It should be something likepublic function validation_form($name, $message, $subject, $email)
. Else, the method does not have access to any of the values frompostAction()
.I don't knot if you can throw an
Exception()
with an empty message, and I'm not sure if thevalidate_form()
method will work as expected, but you can try and open another question if new errors occur :)From your
postAction()
, call the method like this:
Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);
...assuming you defined your model namespace in your config.xml
file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)
I see several issues here:
your method
validation_form()
does not take any parameters. It should be something likepublic function validation_form($name, $message, $subject, $email)
. Else, the method does not have access to any of the values frompostAction()
.I don't knot if you can throw an
Exception()
with an empty message, and I'm not sure if thevalidate_form()
method will work as expected, but you can try and open another question if new errors occur :)From your
postAction()
, call the method like this:
Mage::getModel('mymodule/validation')->validate_form($name, $message, $subject, $email);
...assuming you defined your model namespace in your config.xml
file. If you didn't, search for a tutorial how to define a basic Magento 1 module - it's easy ;)
answered 21 hours ago
simonthesorcerersimonthesorcerer
3,53721127
3,53721127
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
add a comment |
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
Thanks, passed the values to the function and it all worked, thanks again)
– Рома Лытарь
21 hours ago
add a comment |
Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
Рома Лытарь is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f263333%2fhow-to-call-controller-method-from-another-controller%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown