[fw-general] Dynamic form validation
Hi all, An issue I come across reasonably regularly with ZF2 forms is dynamically setting validation rules based on other elements in the form. For example, let’s say I have a checkout form, where I capture users personal details and payment details. So would could maybe have a PaymentForm, with a PaymentDetails fieldset and a PersonalDetails fieldset. Each fieldset could have its own input filter and hence validate itself when the form is validated. All good. Now, what if we want the user to either be able to pay via credit card or PayPal. For this we might take the PaymentDetails fieldset further, by adding two sub fieldsets, CreditCardDetails and PayPal details. Within the PaymentDetails fieldset there might be a select option which allows the user to choose a credit card type or PayPal. If they choose PayPal, any values in the CreditCard fieldset are irrelevant, and shouldn’t be validated. I belive I should be using validation groups for this, but at what point do I set the validation group, should I do this in my controller action where the form is submitted, but before it is validated: Essentially getting the submitted value for the ‘payment type’ select option and manipulating the form input groups accordingly?? This I believe will work, but it would seem to tie the forms underlying logic to the controller a bit too much. Am I missing something, or would this be the ‘recommended way’? Cheers, Greg. -- List: fw-general@lists.zend.com Info: http://framework.zend.com/archives Unsubscribe: fw-general-unsubscr...@lists.zend.com
[fw-general] Form collections and dependencies
work around. In actual fact, there isn't much validation that can be done here, the user selects options for which there is always a default value. --- 2015-05-27T10:43:00+01:00 DEBUG (7): post data is Zend\Stdlib\Parameters Object ( [storage:ArrayObject:private] => Array ( [divertsFieldset] => Array ( [diverts] => Array ( [0] => Array ( [id] => 40 [destinationSetId] => 6 ) [1] => Array ( [id] => 41 [destinationSetId] => 9 ) [2] => Array ( [id] => 42 [destinationSetId] => 19 ) [3] => Array ( [id] => 43 [destinationSetId] => 11 ) ) ) ) ) 2015-05-27T10:43:00+01:00 DEBUG (7): form is not validArray ( [divertsFieldset] => Array ( [diverts] => Array ( [5] => Array ( [destinationSetId] => Array ( [isEmpty] => Value is required and can't be empty ) ) ) ) ) --- Cheers, Greg. -- Greg Frith Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
Re: [fw-general] Validating route params are loading entities from route params
Thanks for your advice and the link Daniel. I'll take a look sounds like a good option. To save the controller also having to do a similar DB query to pull the entity back, I'm guessing that I could store it in a session variable from within the preDispatch. I'm also using Doctrine, so another alternative would be to just query again and allow the doctrine entity cache to take care of this 'caching' element. Cheers, Greg On Friday, 22 May 2015 at 14:20, Daniel Latter wrote: > Hi Greg, > > You could register a preDispatch event in your module's module.php. > > For example, we use a preDispatch event to check if a user is logged in when > accessing certain pages. > > You could easily check for a valid "TopEvent" from inside your preDispatch > method, and redirect accordingly. > > For example: > > https://gist.github.com/rettal/4a6e9ae973ed09fae382 > > The example above checks if logged in, but can easily be adapted to suit your > needs I think, > > Daniel. > > > > > On 22 May 2015 at 13:35, Greg Frith (mailto:gfr...@gmail.com)> wrote: > > Hi all, > > > > I'm developing a ZF2 site which has a booking process for events. The > > booking process part of the site has consistent URLs like: > > > > http://mysite.com/book/TopEvent/availability > > http://mysite.com/book/TopEvent/seats > > http://mysite.com/book/TopEvent/payment > > http://mysite.com/book/TopEvent/confirm > > > > I have an event entity stored in a relational database, that amongst other > > things has a 'url_name' field which is used to reference the event in urls, > > a bit nicer than using plain old ids. So in the above URL examples, the > > 'url_name' is TopEvent. > > > > I have a controller names BookingController which has all the actions for > > the above sample URLs, for example seatsAction. Currently, at the start of > > each action I'm having to pull the 'url_name' parameter from the params, > > and search for the event by url_name in my database. If no event is found, > > I return 404. I have a controller plugin to help with this, and the code > > looks something like: > > > > public function seatsAction() > > { > > // Check we have valid event > > if (!$event = $this->SIL()->getEventFromRoute()) { > > $this->logger->err("On seats page with no valid event, returning 404"); > > $this->getResponse()->setStatusCode(404); > > return; > > } > > …. > > > > > > If I have 8 actions in my booking controller, this gets a bit repetitive. > > Essentially, I'd like a way to return a 404 on all routes/action where the > > event cannot be found. > > > > And finally to the crux of my mail, I'd like some advice on the best way to > > do this? > > > > Perhaps I should be listening for some event within my controller > > (dispatch?) and doing my check here (can I return 404 from this). > > > > Or should I override the parent controllers onDispatch event? > > > > Or, could I take this further and create a custom router that validates > > this part of the URL against the database? If I went down this route, > > could that custom router also load the entity for use within that request? > > > > Any advise greatly appreciated. > > > > Cheers, > > Greg. > > > > :wq
[fw-general] Validating route params are loading entities from route params
Hi all, I'm developing a ZF2 site which has a booking process for events. The booking process part of the site has consistent URLs like: http://mysite.com/book/TopEvent/availability http://mysite.com/book/TopEvent/seats http://mysite.com/book/TopEvent/payment http://mysite.com/book/TopEvent/confirm I have an event entity stored in a relational database, that amongst other things has a 'url_name' field which is used to reference the event in urls, a bit nicer than using plain old ids. So in the above URL examples, the 'url_name' is TopEvent. I have a controller names BookingController which has all the actions for the above sample URLs, for example seatsAction. Currently, at the start of each action I'm having to pull the 'url_name' parameter from the params, and search for the event by url_name in my database. If no event is found, I return 404. I have a controller plugin to help with this, and the code looks something like: public function seatsAction() { // Check we have valid event if (!$event = $this->SIL()->getEventFromRoute()) { $this->logger->err("On seats page with no valid event, returning 404"); $this->getResponse()->setStatusCode(404); return; } …. If I have 8 actions in my booking controller, this gets a bit repetitive. Essentially, I'd like a way to return a 404 on all routes/action where the event cannot be found. And finally to the crux of my mail, I'd like some advice on the best way to do this? Perhaps I should be listening for some event within my controller (dispatch?) and doing my check here (can I return 404 from this). Or should I override the parent controllers onDispatch event? Or, could I take this further and create a custom router that validates this part of the URL against the database? If I went down this route, could that custom router also load the entity for use within that request? Any advise greatly appreciated. Cheers, Greg. :wq
[fw-general] Parameters and redirects
Hi all, I have just sent the below message from a different account, but there seems to have been some problem in my subscription and the message hasn't been circulated. I have checked the archives and can only apologise if the message does finally appear and I end up double posting. A simple one I hope... I'm trying to put together a redirect request, based on parameters from an original request. Essentially, I want to replace one parameter and then redirect the request with all the additional original parameters. I could do something like this, but can't help thinking there must be a nicer way. $params = $this->_getAllParams(); $params['new_param'] = 'some new param value'; unset($params['old_param']); unset($params['action']); unset($params['controller']); unset($params['module']); $this->_helper->Redirector->gotoRoute($params,'newRoute'); Obviously the bit I'm most unhappy about is having to unset the controller, action and module name to prevent these being passed as params to the new route. I thought $this->_request->getUserParams() might have done the trick, but unfortunately not. It works, but its not nice... Any advice most welcome. :wq
[fw-general] Call actions via CLI
Hi all, I'm currently using curl to call some actions at timed intervals using cron. This is a far from ideal method, but has provided a quick fix for now. I'd much prefer to call the actions via CLI, but I notice that there is currently no way to handle such requests. I appreciate there is currently a proposal in placed for Zend_Controller_Request_Cli (http://framework.zend.com/wiki/display/ZFPROP/Zend_Controller_Request_Cli ), but this doesn't looked to have been touched for some time. Just wondering if there are any plans afoot to proceed with a CLI request object, or how others are currently using ZF with the CLI. :wq Greg.
Re: [fw-general] Zend_Form - config & HtmlTag
div input_submit :wq Greg On 2 Apr 2008, at 16:21, Matthew Weier O'Phinney wrote: Answer way down below... -- Greg Frith <[EMAIL PROTECTED]> wrote (on Wednesday, 02 April 2008, 03:17 PM +0100): I fear this might not be my first post to the group in the next day or to in relation to Zend_Form, I just don't seem to be getting a complete grasp of it yet. My first problem. I am trying to implement mark-up for an element like this: Password: Forgotten Password I configure my form using an XML config. I can get the form element wrapped in the div without any problems using the following config snippet (which is the element configuration for this element): password Password: alnum true StringLength 5 20 ViewHelper label HtmlTag div input_password Now I understand that I cannot add a second HtmlTag decorator, but can anyone suggest any other way of achieving my element layout (adding the additional 'Forgotten Password' after the input element) without using a customer decorator class? Actually, you *can* add additional decorators of the same class using aliasing. Try this: ViewHelper Label HtmlTag div input_password HtmlTag p The relevant parts are the and decorators -- notice that the type in each is an array consisting of a single key/value pair -- the key is the internal alias by which you'll refer to it, and the value is the actual decorator type. That said, you probably want to use the element description for setting that particular content, and then add a 'Description' decorator to your decorator stack. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
[fw-general] Zend_Form - config & HtmlTag
Hi all, I fear this might not be my first post to the group in the next day or to in relation to Zend_Form, I just don't seem to be getting a complete grasp of it yet. My first problem. I am trying to implement mark-up for an element like this: Password: Forgotten Password I configure my form using an XML config. I can get the form element wrapped in the div without any problems using the following config snippet (which is the element configuration for this element): password Password: alnum true StringLength 5 20 ViewHelper label HtmlTag div input_password Now I understand that I cannot add a second HtmlTag decorator, but can anyone suggest any other way of achieving my element layout (adding the additional 'Forgotten Password' after the input element) without using a customer decorator class? The more observant amongst the group might notice I posted a different Zend_Form question a week or so ago... Don't worry... I'm not that slow, I've only just got back to my forms today!! :wq Greg.
[fw-general] Zend_Form, config and numeric option values
Hi all, I've hit a slight issue with Zend_Form and my XML config file and am wondering if anyone can suggest a way to work around this. Here is the definition for one of my forms fields from my config file: radio How would you rate the show: <5>Loved it <4>It was good <3>So / So <2>Not so Great <1>Not my thing I think the problem should be quite evident. I wish values for each option to be numeric, however numeric values are not valid XML element names as passed in via the multiOptions block. Can anybody suggest any alternative way of creating the options from an XML config which would allow me to use numeric values. I appreciate I could set the options on this element from within my code, but I would rather avoid this if at all possible. :eq Greg Frith.
Re: [fw-general] Zend_Form Config
Hi all, Thanks to assistance from Matthew, I have now resolved this problem by changing my Zend code base to the latest trunk (r8024). Apologies for reporting this issue without first checking the latest code. FYI I was previously using 1.5.0PR. :wq G. On 15 Feb 2008, at 08:18, Greg Frith wrote: On 14 Feb 2008, at 21:50, Matthew Weier O'Phinney wrote: Thanks Matthew, Have tried this (see below) but still the extra prefix and path are not added to element pluginloaders. Odd -- I just tried this on my own box, using the config you provided, and it worked fine; here's a portion of a var_export() I did on my form object: 'VALIDATE' => Zend_Loader_PluginLoader::__set_state(array( '_prefixToPaths' => array ( 'Zend_Validate_' => array ( 0 => 'Zend/Validate/', ), 'WETB_Validate_' => array ( 0 => 'WETB/Validate/', ), ), '_loadedPlugins' => array ( 'WordChars' => 'WETB_Validate_WordChars', 'StringLength' => 'Zend_Validate_StringLength', ), '_useStaticRegistry' => NULL, )), As you can see, the plugin loader has the path, and the validator was loaded (I created a dummy validator so I could test). Are you using current trunk? If not, could you send me a copy of your code and config file offline so I can see if I can diagnose the issue? -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ Hi Matthew, No sorry, I should have specified earlier, I am using version 1.5.0PR. I will check out the trunk and try again before we go any further. Many thanks, :wq Greg
Re: [fw-general] Zend_Form Config
On 14 Feb 2008, at 21:50, Matthew Weier O'Phinney wrote: Thanks Matthew, Have tried this (see below) but still the extra prefix and path are not added to element pluginloaders. Odd -- I just tried this on my own box, using the config you provided, and it worked fine; here's a portion of a var_export() I did on my form object: 'VALIDATE' => Zend_Loader_PluginLoader::__set_state(array( '_prefixToPaths' => array ( 'Zend_Validate_' => array ( 0 => 'Zend/Validate/', ), 'WETB_Validate_' => array ( 0 => 'WETB/Validate/', ), ), '_loadedPlugins' => array ( 'WordChars' => 'WETB_Validate_WordChars', 'StringLength' => 'Zend_Validate_StringLength', ), '_useStaticRegistry' => NULL, )), As you can see, the plugin loader has the path, and the validator was loaded (I created a dummy validator so I could test). Are you using current trunk? If not, could you send me a copy of your code and config file offline so I can see if I can diagnose the issue? -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/ Hi Matthew, No sorry, I should have specified earlier, I am using version 1.5.0PR. I will check out the trunk and try again before we go any further. Many thanks, :wq Greg
Re: [fw-general] Zend_Form Config
On 14 Feb 2008, at 13:11, Matthew Weier O'Phinney wrote: -- Greg Frith <[EMAIL PROTECTED]> wrote (on Thursday, 14 February 2008, 12:24 PM +): I'm trying to use my XML config file to add custom validator paths to every element in a Zend_Form instance. Here is an extract from my configuration file (this is the config tree I pass to new Zend_Form): userRegister /authentication/register/ post The above should be singular (even though it allows for multiple entries): 'elementPrefixPath'. That should solve your issue, including the exception from attempting to load the custom validator class. Thanks Matthew, Have tried this (see below) but still the extra prefix and path are not added to element pluginloaders. userRegister /authentication/register/ post WETB_Validate WETB/Validate validate text Surname: StringLength 1 20 . function registerAction() { $form = new Zend_Form($this->config->forms->userRegistration); $fn = $form->getElement('firstname'); $p = $fn->getPluginLoader('validate'); print_r($p->getPaths()); . Will still output: Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) ) :wq G WETB_Validate WETB/Validate validate select . Here is a snippet of the function I am then using to test: function registerAction() { $form = new Zend_Form($this->config->forms->userRegistration); $fn = $form->getElement('firstname'); $p = $fn->getPluginLoader('validate'); print_r($p->getPaths()); . The print_r statement outputs: Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) ) I would expect this array to also contain the custom path. In addition, the plugin loader throws an exception if I try to use a custom validator class. Any ideas? :wq Greg. -- Matthew Weier O'Phinney PHP Developer| [EMAIL PROTECTED] Zend - The PHP Company | http://www.zend.com/
[fw-general] Zend_Form Config
Hi all, I'm trying to use my XML config file to add custom validator paths to every element in a Zend_Form instance. Here is an extract from my configuration file (this is the config tree I pass to new Zend_Form): userRegister /authentication/register/ post WETB_Validate WETB/Validate validate select . Here is a snippet of the function I am then using to test: function registerAction() { $form = new Zend_Form($this->config->forms->userRegistration); $fn = $form->getElement('firstname'); $p = $fn->getPluginLoader('validate'); print_r($p->getPaths()); . The print_r statement outputs: Array ( [Zend_Validate_] => Array ( [0] => Zend/Validate/ ) ) I would expect this array to also contain the custom path. In addition, the plugin loader throws an exception if I try to use a custom validator class. Any ideas? :wq Greg.
[fw-general] Routing problem
Hi all, I'm having some routing problems which I don't necessarily think the group are going to be able to answer directly, but maybe give me some pointers as to how I may debug further. I have developed a site on my local machine where everything is working just fine. Yesterday I copied the site over to a second development server for my colleagues to start reviewing. However, on the development server I'm getting an awful lot of Zend_Controller_Dispatcher_Exception exceptions thrown with the message 'Invalid controller specified (). I say an awful lot as not every request results in this. My default index controller works fine, as does my Book controller, but all others fail (please note that book controller is the real thing, and not a typical library book example file! Its part of a booking process). My directory structure is as follows: www/application/ www/application/config/ www/application/modules/ www/application/modules/default/ www/application/modules/default/controller/ www/application/modules/default/controller/BookController.php www/application/modules/default/controller/ComingSoonController.php www/application/modules/default/controller/IndexController.php www/application/modules/default/controller/StaticPagesController.php www/application/modules/default/views/ www/application/templates/ www/htdocs/ <- doc root As I say, the BookController and IndexController work fine, but ComingSoonController and StaticPagesController are not found. During a request for /comingsoon/index the request object looks like this: 2007-08-15T08:03:32+01:00 DEBUG (7): Zend_Controller_Request_Http Object ( [_requestUri:protected] => /default/ComingSoon/index/ [_baseUrl:protected] => [_basePath:protected] => [_pathInfo:protected] => /default/ComingSoon/index/ [_params:protected] => Array ( [module] => default [controller] => ComingSoon [action] => index ) [_aliases:protected] => Array ( ) [_dispatched:protected] => 1 [_module:protected] => default [_moduleKey:protected] => module [_controller:protected] => ComingSoon [_controllerKey:protected] => controller [_action:protected] => index [_actionKey:protected] => action ) So the correct modules, controller and action parameters are being taken from the URL. All the controllers are working fine with exactly the same code on a local development machine. The only real difference being the the development machine has a local hostname and uses Apache Virtual Hosts, whereas the new testing server on which the site fails is accessed over the internet via its IP address. There is no domain registered against it. Some relevant lines from my bootstrap: // Get front controller $controller = Zend_Controller_Front::getInstance(); $modules = array('default',"$modulesDir/default/controller/"); $controller->setControllerDirectory($modules); * NOTE THE ABOVE LINES HAVE BEEN ADDED TO TRY AND RESOLVE THE ISSUE, THEY WERE NOT REQUIRED ON THE WORKING SERVER * // Add some additional routes - if we keep these they should come from a config $router = $controller->getRouter(); $router->addRoute('shows', new Zend_Controller_Router_Route ('shows/:event', array('controller'=>'findashow','action'=>'showInfo'))); $router->addRoute('InsiderTips',new Zend_Controller_Router_Route ('insidertips/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'insidertips', 'category'=>'insidertips'))); $router->addRoute('whyus',new Zend_Controller_Router_Route ('whyus/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'whyus', 'category'=>'whyus'))); $router->addRoute('whybookapackage',new Zend_Controller_Router_Route ('whybookapackage/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'whybookapackage', 'category'=>'whybookapackage'))); Could anyone suggest any where I might start looking and debugging further? Perhaps somewhere where the actual path to the action controller is generated and an attempt is made to instantiate the class might give me some clues as to what's going wrong? -- Greg Frith [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith
Re: [fw-general] Routing problems - Invalid controller specified
Thanks Simon. Of course. For the benefit of the thread, my first server is OS X using the OSX Extended filesystem, which preserves case but isn't case sensitive. The second server is Ubuntu using ext3 filesystem which is case sensitive. I should have spotted this earlier! Now for a bit of re-naming! Beware to those developing on OS X! Many thanks, Greg. On 15 Aug 2007, at 09:34, Simon Mundy wrote: No great magic here - your first server is obvious case-insensitive for filenames and the second is not. The router uses CamelCase for its class names, but the _whole_ controller name is turned into word case for the sake of consistency. So MyNewRssController should really be written as MynewrssController in both the filename and the class declaration. Cheerio It works! I didn't think this one was going to be so simple to solve! Well kind of, so why is one box treating case differently to another?? I'll have to carefully read the docs on naming conventions. Thanks Simon. On 15 Aug 2007, at 08:50, Simon Mundy wrote: Hi Greg What happens on the new box if you have 'ComingsoonController.php' (with the lowercase 's') and the class is named 'ComingsoonController'? Could anyone suggest any where I might start looking and debugging further? Perhaps somewhere where the actual path to the action controller is generated and an attempt is made to instantiate the class might give me some clues as to what's going wrong? -- Simon Mundy | Director | PEPTOLAB """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com Many thanks, -- Greg Frith DGFSolutions - Independent IT Consultancy, Troubleshooting and Development [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith -- Simon Mundy | Director | PEPTOLAB """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com Many thanks, -- Greg Frith DGFSolutions - Independent IT Consultancy, Troubleshooting and Development [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith
Re: [fw-general] Routing problems - Invalid controller specified
It works! I didn't think this one was going to be so simple to solve! Well kind of, so why is one box treating case differently to another?? I'll have to carefully read the docs on naming conventions. Thanks Simon. On 15 Aug 2007, at 08:50, Simon Mundy wrote: Hi Greg What happens on the new box if you have 'ComingsoonController.php' (with the lowercase 's') and the class is named 'ComingsoonController'? Could anyone suggest any where I might start looking and debugging further? Perhaps somewhere where the actual path to the action controller is generated and an attempt is made to instantiate the class might give me some clues as to what's going wrong? -- Simon Mundy | Director | PEPTOLAB """ " "" """""" "" "" """"""" " "" """"" " """"" " """""" "" " 202/258 Flinders Lane | Melbourne | Victoria | Australia | 3000 Voice +61 (0) 3 9654 4324 | Mobile 0438 046 061 | Fax +61 (0) 3 9654 4124 http://www.peptolab.com Many thanks, -- Greg Frith DGFSolutions - Independent IT Consultancy, Troubleshooting and Development [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith
[fw-general] Routing problems - Invalid controller specified
Hi all, I'm having some routing problems which I don't necessarily think the group are going to be able to answer directly, but maybe give me some pointers as to how I may debug further. I have developed a site on my local machine where everything is working just fine. Yesterday I copied the site over to a second development server for my colleagues to start reviewing. However, on the development server I'm getting an awful lot of Zend_Controller_Dispatcher_Exception exceptions thrown with the message 'Invalid controller specified (). I say an awful lot as not every request results in this. My default index controller works fine, as does my Book controller, but all others fail (please note that book controller is the real thing, and not a typical library book example file! Its part of a booking process). My directory structure is as follows: www/application/ www/application/config/ www/application/modules/ www/application/modules/default/ www/application/modules/default/controller/ www/application/modules/default/controller/BookController.php www/application/modules/default/controller/ComingSoonController.php www/application/modules/default/controller/IndexController.php www/application/modules/default/controller/StaticPagesController.php www/application/modules/default/views/ www/application/templates/ www/htdocs/ <- doc root As I say, the BookController and IndexController work fine, but ComingSoonController and StaticPagesController are not found. During a request for /comingsoon/index the request object looks like this: 2007-08-15T08:03:32+01:00 DEBUG (7): Zend_Controller_Request_Http Object ( [_requestUri:protected] => /default/ComingSoon/index/ [_baseUrl:protected] => [_basePath:protected] => [_pathInfo:protected] => /default/ComingSoon/index/ [_params:protected] => Array ( [module] => default [controller] => ComingSoon [action] => index ) [_aliases:protected] => Array ( ) [_dispatched:protected] => 1 [_module:protected] => default [_moduleKey:protected] => module [_controller:protected] => ComingSoon [_controllerKey:protected] => controller [_action:protected] => index [_actionKey:protected] => action ) So the correct modules, controller and action parameters are being taken from the URL. All the controllers are working fine with exactly the same code on a local development machine. The only real difference being the the development machine has a local hostname and uses Apache Virtual Hosts, whereas the new testing server on which the site fails is accessed over the internet via its IP address. There is no domain registered against it. Some relevant lines from my bootstrap: // Get front controller $controller = Zend_Controller_Front::getInstance(); $modules = array('default',"$modulesDir/default/controller/"); $controller->setControllerDirectory($modules); * NOTE THE ABOVE LINES HAVE BEEN ADDED TO TRY AND RESOLVE THE ISSUE, THEY WERE NOT REQUIRED ON THE WORKING SERVER * // Add some additional routes - if we keep these they should come from a config $router = $controller->getRouter(); $router->addRoute('shows', new Zend_Controller_Router_Route ('shows/:event', array('controller'=>'findashow','action'=>'showInfo'))); $router->addRoute('InsiderTips',new Zend_Controller_Router_Route ('insidertips/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'insidertips', 'category'=>'insidertips'))); $router->addRoute('whyus',new Zend_Controller_Router_Route ('whyus/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'whyus', 'category'=>'whyus'))); $router->addRoute('whybookapackage',new Zend_Controller_Router_Route ('whybookapackage/:article', array('controller'=>'staticPages', 'artion'=>'index', 'article'=>'whybookapackage', 'category'=>'whybookapackage'))); Could anyone suggest any where I might start looking and debugging further? Perhaps somewhere where the actual path to the action controller is generated and an attempt is made to instantiate the class might give me some clues as to what's going wrong? Many thank, Greg Frith.
Re: [fw-general] Zend_Session without cookies
HI Ramon, Thanks for the link and info. I am using Firefox for my testing. Although each of the issues described under that link are very interesting, I'm don't think any are relevant to this issue. Two points which I mentioned earlier and I feel are important to pin pointing the problem: 1. The stand alone PHP script (shown in my original message) works. PHP appends the session to the link as it renders the page and the browser obviously passes this back (as really its just a URL parameter that happens to be called PHPSESSID). 2. When testing through the framework, PHP is *not* appending the PHPSESSID to links rendered in my view. Many thanks, Greg. On 26 Jul 2007, at 12:44, Ramon de la Fuente wrote: Hi Greg, This could have something to do with the security within the browser. I had the same kind of issue where the PHP session ID wasn't resent to the server by the browser, but only in IE. FireFox worked fine. I also use local url's with entries in the local hosts file, and I figured out that when using underscores in the domain name, IE rejects the header. Here's a longer list of reasons why this can occur: http://blog.genotrance.com/2006/11/23/session-cookies-rejected-by- internet-explorer/ Hope this helps.. Ramon Greg Frith wrote: Hi all, I have a requirement to implement sessions on 'part' of a site. As the session is not required for the majority of pages, I am only calling Zend_Session::start() in the init() method of the controller which controls all the pages which require the session. The problem is that my client wants the site to be usable with cookies disabled. I appreciate all the security concerns, this is another issue! So, I have to use session ID's passed in the URL. This is what I have done: A section in my config file: [session] use_cookies = off use_only_cookies = off strict = on use_trans_sid = 1 Then as part of the bootstrap process: // Setup session options if ($config->session) { Zend_Session::setOptions($config->session->toArray()); } So we should now have the Zend_Session configured correctly. Then I have a controller called book with the following functions: public function init() { // Start the session Zend_Session::start(); } public function indexAction() { // Just let the view render for now } Please note that I am using the ViewRenderer helper. In the view: in book/index with session link The URL I use on my local machine for the project is http:// wetb.nidd.local/. So, if i try http://wetb.nidd.local/book/, I see something like: in book/index with session PHPSESSID=e52d7461d4d021298ccb2e77316d3cba link But here is the problem: each time I refresh the page or click the 'link', I get a different session ID. In addition, the PHPSESSID is not getting appended to the link I put in my view. I have also tried setting the session parameter directly in my php.ini file. The following straight php script: link"; echo SID; ?> Gives the results I would expect, with the PHPSESSID appended to my link and same session id displayed on each click of the link or page refresh. I would much appreciate any hints or tips that could be provided to get URL based session working in my project. Many thanks, Greg Frith. Many thanks, -- Greg Frith DGFSolutions - Independent IT Consultancy, Troubleshooting and Development [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith
[fw-general] Zend_Session without cookies
Hi all, I have a requirement to implement sessions on 'part' of a site. As the session is not required for the majority of pages, I am only calling Zend_Session::start() in the init() method of the controller which controls all the pages which require the session. The problem is that my client wants the site to be usable with cookies disabled. I appreciate all the security concerns, this is another issue! So, I have to use session ID's passed in the URL. This is what I have done: A section in my config file: [session] use_cookies = off use_only_cookies = off strict = on use_trans_sid = 1 Then as part of the bootstrap process: // Setup session options if ($config->session) { Zend_Session::setOptions($config->session->toArray()); } So we should now have the Zend_Session configured correctly. Then I have a controller called book with the following functions: public function init() { // Start the session Zend_Session::start(); } public function indexAction() { // Just let the view render for now } Please note that I am using the ViewRenderer helper. In the view: in book/index with session link The URL I use on my local machine for the project is http:// wetb.nidd.local/. So, if i try http://wetb.nidd.local/book/, I see something like: in book/index with session PHPSESSID=e52d7461d4d021298ccb2e77316d3cba link But here is the problem: each time I refresh the page or click the 'link', I get a different session ID. In addition, the PHPSESSID is not getting appended to the link I put in my view. I have also tried setting the session parameter directly in my php.ini file. The following straight php script: link"; echo SID; ?> Gives the results I would expect, with the PHPSESSID appended to my link and same session id displayed on each click of the link or page refresh. I would much appreciate any hints or tips that could be provided to get URL based session working in my project. Many thanks, Greg Frith.
Re: [fw-general] Data models
Thanks Bill, I've just about come to this conclusion myself having read through the great thread suggested by Karol. Essentially now I know there is no one best way of doing things. Many thanks, Greg Frith. On 20 Jul 2007, at 16:52, Bill Karwin wrote: Right; I don't believe it's appropriate to assume that a "model" can simply extend a table or row object. It's better to write your own model class, extending nothing, that may use a table or row object, and may also use other sources of data, such as a SOAP service. Regards, Bill Karwin -----Original Message- From: Greg Frith [mailto:[EMAIL PROTECTED] Sent: Friday, July 20, 2007 4:35 AM To: fw-general@lists.zend.com; [EMAIL PROTECTED] Subject: [fw-general] Data models Hi list, A request for thoughts/advice if I may. I have an entity which I wish to model, let's say for now it's a car. I want to be able to use a 'car' object (or list of car objects) in my view. For example $car->colour, $car->engineSize. Now, some of the information my site presents about the car comes from a SOAP web service running on another server, and some additional information comes from a local MySQL database. I understand all the Zend_Db_* classes and how I might use them to model my database car info. But I'm not too sure how to create an object that represents a car combining information from both the Web Service and the database. If for example I was to extend Zend_Db_Table_Row_Abstract to represent the car, could I add additional public fields to hold the data obtained through the Web Service without creating problems when I use ->save and such methods? Or would I perhaps be better creating a car class that doesn't extend Zend_Db_Table_Row_Abstract. Then either use the basic Zend_Db class's or extend them slightly to do the DB work for a car. Calling the various find and save methods from the car class? Thoughts? Many thanks, Greg Frith. -- Greg Frith [EMAIL PROTECTED] : +44 7970 925 257 MSN: [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] Skype: gregfrith
[fw-general] Data models
Hi list, A request for thoughts/advice if I may. I have an entity which I wish to model, let's say for now it's a car. I want to be able to use a 'car' object (or list of car objects) in my view. For example $car->colour, $car->engineSize. Now, some of the information my site presents about the car comes from a SOAP web service running on another server, and some additional information comes from a local MySQL database. I understand all the Zend_Db_* classes and how I might use them to model my database car info. But I'm not too sure how to create an object that represents a car combining information from both the Web Service and the database. If for example I was to extend Zend_Db_Table_Row_Abstract to represent the car, could I add additional public fields to hold the data obtained through the Web Service without creating problems when I use ->save and such methods? Or would I perhaps be better creating a car class that doesn't extend Zend_Db_Table_Row_Abstract. Then either use the basic Zend_Db class's or extend them slightly to do the DB work for a car. Calling the various find and save methods from the car class? Thoughts? Many thanks, Greg Frith.