2010年10月23日星期六

Re: [fw-mvc] Forms and HTML

The escape is used the same way as label, required and multioption:

$this->addElement('select', 'types', array(
'label' => 'Some <span>html</span> label',
'required' => true,
'escape' => false,
'multiOptions => array(...)
);

Regards, Jurian
--
Jurian Sluiman
CTO Soflomo V.O.F.
http://soflomo.com

On Friday 22 Oct 2010 21:53:59 Thomas List wrote:
> I've been trying without any luck to add HTML to a Zend_Form. I started
> out with just trying to add a font to a label for one of the fields in my
> form:
>
> $this->addElement('select','types', array(
> 'label' => 'What type of home do you live in:',
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home',
> 'New Construction' => 'New Construction', 'Condominium' => 'Condominium',
> 'Apartment' => 'Apartment',),));
>
>
> but when I add the html, Zend just renders it as text. I've read something
> about adding an esacape=>false to $decorators element or something, but I
> really am not sure how to do so. I would really appreciate some guidance
> on this, as I can't seem to find a straightforward example.
>
> Thanks,
> Thomas List

2010年10月22日星期五

Re: [fw-mvc] about Routes

Here's your problem: YOUR ROUTES ARE ALL THE SAME AND YOU HAVE 3000 OF

THEM! Every time someone accesses your site, the router has to go
through EACH DEFINITION to find the right one to use.

Define only a single route and use that:

routes.cates.route = "list/:id/:page"
routes.cates.defaults.module = "default"
routes.cates.defaults.controller = "list"
routes.cates.defaults.action = "index"
routes.cates.defaults.id = 1
routes.cates.defaults.page = 1
routes.cates.reqs.id = "\d+"
routes.cates.reqs.page = "\d+"

This will fix your problem.


On 10/22/2010 8:01 PM, Expertics wrote:
> Hi,
>
> I have 3000 definitions in my config.ini .
>
> routes.cates1.route = "list1/:page"
> routes.cates1.defaults.module = "default"
> routes.cates1.defaults.controller = "list"
> routes.cates1.defaults.action = "index"
> routes.cates1.defaults.id = 1
> routes.cates1.defaults.page = 1
> routes.cates1.reqs.page = "\d+"
>
> ....
> ....
>
> routes.cates3000.route = "list3000/:page"
> routes.cates3000.defaults.module = "default"
> routes.cates3000.defaults.controller = "list"
> routes.cates3000.defaults.action = "index"
> routes.cates3000.defaults.id = 3000
> routes.cates3000.defaults.page = 3000
> routes.cates3000.reqs.page = "\d+"
>
>
> I think my web site (it isn´t production) is slower than before. This
> is Okay or I need other solution.
>
> bye
>
>
> George
>
>

Re: [fw-mvc] about Routes

That is not okay at all. Use an :id token in the pattern and you could
reduce all of that into one route.

-- Mon


On Sat, Oct 23, 2010 at 9:01 AM, Expertics <expertics@gmail.com> wrote:

> Hi,
>
> I have 3000 definitions in my config.ini .
>
> routes.cates1.route = "list1/:page"
> routes.cates1.defaults.module = "default"
> routes.cates1.defaults.controller = "list"
> routes.cates1.defaults.action = "index"
> routes.cates1.defaults.id = 1
> routes.cates1.defaults.page = 1
> routes.cates1.reqs.page = "\d+"
>
> ....
> ....
>
> routes.cates3000.route = "list3000/:page"
> routes.cates3000.defaults.module = "default"
> routes.cates3000.defaults.controller = "list"
> routes.cates3000.defaults.action = "index"
> routes.cates3000.defaults.id = 3000
> routes.cates3000.defaults.page = 3000
> routes.cates3000.reqs.page = "\d+"
>
>
> I think my web site (it isn´t production) is slower than before. This is
> Okay or I need other solution.
>
> bye
>
>
> George
>
>

[fw-mvc] about Routes

Hi,

I have 3000 definitions in my config.ini .

routes.cates1.route = "list1/:page"
routes.cates1.defaults.module = "default"
routes.cates1.defaults.controller = "list"
routes.cates1.defaults.action = "index"
routes.cates1.defaults.id = 1
routes.cates1.defaults.page = 1
routes.cates1.reqs.page = "\d+"

....
....

routes.cates3000.route = "list3000/:page"
routes.cates3000.defaults.module = "default"
routes.cates3000.defaults.controller = "list"
routes.cates3000.defaults.action = "index"
routes.cates3000.defaults.id = 3000
routes.cates3000.defaults.page = 3000
routes.cates3000.reqs.page = "\d+"


I think my web site (it isn´t production) is slower than before. This is
Okay or I need other solution.

bye


George

Re: [fw-mvc] Forms and HTML

Thomas,

You would either have to create a decorator or you can echo out all the
form elements in the view with the label turned off.

An example with the label decorator turned off:
$this->email
->setRequired(true)
->addFilter('StripTags')
->addValidator('EmailAddress')
->*removeDecorator('Label');*

*View:*
<table>
<tr>
<td>YOUR LABEL HERE</td>
<td><?php echo $this->form->email?></td>
</tr>
</table>


You could also just add a class to those elements and do your styling in
CSS.

$this->email
->setOptions(array('class' =>
'CLASS_NAME_HERE'))
->setRequired(true)
->addFilter('StripTags')
->addValidator('EmailAddress')
->removeDecorator('Label');

Tully Rankin
PHP Developer
www.tullyrankin.com


On 10/22/2010 12:53 PM, Thomas List wrote:
> I've been trying without any luck to add HTML to a Zend_Form. I started out with just trying to add a font to a label for one of the fields in my form:
>
> $this->addElement('select','types', array(
> 'label' => 'What type of home do you live in:',
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));
>
>
> but when I add the html, Zend just renders it as text. I've read something about adding an esacape=>false to $decorators element or something, but I really am not sure how to do so. I would really appreciate some guidance on this, as I can't seem to find a straightforward example.
>
> Thanks,
> Thomas List
>
>

[fw-mvc] Forms and HTML

I've been trying without any luck to add HTML to a Zend_Form. I started out with just trying to add a font to a label for one of the fields in my form:

$this->addElement('select','types', array(
'label' => 'What type of home do you live in:',
'required' => true,
'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));

but when I add the html, Zend just renders it as text. I've read something about adding an esacape=>false to $decorators element or something, but I really am not sure how to do so. I would really appreciate some guidance on this, as I can't seem to find a straightforward example.

Thanks,
Thomas List

Re: [fw-mvc] Referer

You can avoid the referrer if you keep track of the current page before
redirecting to login. Once of the solutions I've used goes a little
something like this:

// on page that needs login
$session = new Zend_Session_Namespace('login');
$session->gotoAfterLogin = $this->_request->getRequestUri();
return $this->_redirect('login');

// on successful login
$session = new Zend_Session_Namespace('login');
if (isset($session->gotoAfterLogin)) {
$gotoAfterLogin = $session->gotoAfterLogin;
unset($session->gotoAfterLogin);
return $this->_redirect($gotoAfterLogin);
}
return $this->_redirect('/');

To avoid copy/pasting that first bit of code in all of your controllers you
can move it to an action helper. Also note the unset() prior to the redirect
-- if the user logs out and back in you don't want that redirect to occur
again.

--
*Hector Virgen*
Sr. Web Developer
Walt Disney Parks and Resorts Online
http://www.virgentech.com