2010年10月31日星期日

[fw-mvc] Re: Auto HTML escaper module for Zend_View.

Andy,

I knew I could parse and replace view files with Zend_View_Stream. But I
thought it was very slow.

But after I have tested it myself, I changed my mind. (Please check my other
reply.) I must admit your way is more practical and less buggy.

In my opinion, what's important is all values are to be escaped by default
in order not to forget to put escape-flag to suspicious values.

<?= $this->foo; ?> // escaped
<?=~ $this->foo; ?> // raw value

Chikara

--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Auto-HTML-escaper-module-for-Zend-View-tp3019090p3020913.html
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-mvc] Re: Auto HTML escaper module for Zend_View.

My module doesn't parse any files. It just utilizes the power of SPL &
Predefined Interfaces.
http://www.php.net/manual/en/book.spl.php
http://www.php.net/manual/en/reserved.interfaces.php

I have just checked the performance of my view with ab command.
* Intel(R) Xeon(R) CPU L5520 @ 2.27GHz

The results of $ ab -c 5 -n 50.

=== Zend_View

Time taken for tests: 1.721591 seconds
Requests per second: 29.04 [#/sec] (mean)
Time per request: 172.159 [ms] (mean)
Time per request: 34.432 [ms] (mean, across all concurrent requests)
Transfer rate: 426.35 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 1
Processing: 160 170 5.3 170 184
Waiting: 156 167 5.1 167 180
Total: 160 170 5.3 170 184


=== My auto escaper

Time taken for tests: 1.772377 seconds
Requests per second: 28.21 [#/sec] (mean)
Time per request: 177.238 [ms] (mean)
Time per request: 35.448 [ms] (mean, across all concurrent requests)
Transfer rate: 414.70 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 0 0 0.3 0 2
Processing: 160 175 6.3 175 194
Waiting: 157 171 5.6 172 187
Total: 160 175 6.3 175 194


The overhead is bearable for me.
Like you, I hated using preg_* and parsing view files because I thought it
was tremendously slow.
But the truth is that trapping a view file and parsing it with
Zend_View_Stream isn't that slow. (I just have checked it!)

Then the only drawback of it is you could apply any arbitrary rules to your
view files, like writing <% ... %> instead of <?php ... ?>, <?php foreach
... ?> instead of <? loop ... ?>.
If you do so, they aren't 'PHP' any more.

But if you don't care about what your templates look like, Zend_View_Stream
is better way.
And to tell the truth, I don't care, either...

--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Auto-HTML-escaper-module-for-Zend-View-tp3019090p3020887.html
Sent from the Zend MVC mailing list archive at Nabble.com.

2010年10月30日星期六

[fw-mvc] Changing request parameters and Zend Navigation issue

Hi,

I've a pretty standard ZF application with a controller plugin that verifies for ACL things.

If user doesn't have permission to access a certain resource, it will redirect to Auth controller. Something like this:

$request->setModuleName('public')
->setControllerName('auth')
->setActionName('index');

This is done at routeShutdown() method.

The issue is that Zend Navigation still work as if the request was not modified. Example: if request was to index controller, it will behave as if the request still has index as controller and not auth.

My application heavily relies on some Zend Navigation features, so this is an issue to me.

Could this be considered a bug or is it the expected behavior? Any ideas for a workaround?


Thanks!

Fernando Morgenstern
contato@fernandomarcelo.com

Re: [fw-mvc] Auto HTML escaper module for Zend_View.

-- Andrew Collington <php@amnuts.com> wrote
(on Friday, 29 October 2010, 10:17 PM +0100):
> On 2010-10-29 5:51 pm, Matthew Weier O'Phinney wrote:
> >-- chikaram<chikara.miyake@gmail.com> wrote
> >(on Friday, 29 October 2010, 06:23 AM -0700):

<snip>

> I don't know about the *only* way... What I did for a bit of an
> experiment was to extend the Zend_View_Stream class and override the
> stream_open method. It was essentially exactly the same, except
> that I added this before the conversion of short tags to long:
>
> $this->_data = preg_replace(
> '/\<\?\=~ (.*?);? \?>/',
> '<?php echo $this->escape($1); ?>',
> $this->_data
> );
>
> Then all that had to be done was to register the zend.view stream
> wrapper before I knew ZF did:
>
> stream_register_wrapper('zend.view', 'MyStream');
>
> and in any views I just had to do:
>
> <?=~ $this->foo; ?>
>
> Of course, it introduced a non-standard php tag in to the views, but
> it was OK in this instance because 1) it was just an experiment, and
> 2) the code was for wholly in-house applications and none of it
> distributed, so I didn't really have to worry about compatibility,
> short tags, non-standard php tags, etc. But it did work like a
> charm!

That's a _really_ elegant solution, and a perfect use of stream
wrappers. Nice work!

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

2010年10月29日星期五

Re: [fw-mvc] Auto HTML escaper module for Zend_View.

On 2010-10-29 5:51 pm, Matthew Weier O'Phinney wrote:
> -- chikaram<chikara.miyake@gmail.com> wrote
> (on Friday, 29 October 2010, 06:23 AM -0700):
>> I love ZendFramework and I wanted my team use it.
>> But that you couldn't escape vars in view automatically was its biggest
>> drawbacks.
>>
>> So I write this - auto HTML escaper module for Zend_View:
>> http://github.com/chikaram/gnix-view
> You may be interested in work I've been doing on Zend\View in ZF2. In
> that component, I'm separating variable storage into a separate object
> -- which makes auto-escaping trivial:
>
> echo $this->vars('foo'); // escaped
> echo $this->vars()->getRawValue('foo'); // unescaped
>
> It's also configurable, allowing you to disable auto-escaping if a
> particular context does not require it:
>
> $this->vars()->setIsStrict(false);
> echo $this->vars('foo'); // unescaped
>
> In ZF1, the only way to do auto-escaping requires extending Zend_View
> and doing some hackery in __get and getVars (and optionally __set).
> While it's do-able, it's non-trivial.

I don't know about the *only* way... What I did for a bit of an
experiment was to extend the Zend_View_Stream class and override the
stream_open method. It was essentially exactly the same, except that I
added this before the conversion of short tags to long:

$this->_data = preg_replace(
'/\<\?\=~ (.*?);? \?>/',
'<?php echo $this->escape($1); ?>',
$this->_data
);

Then all that had to be done was to register the zend.view stream
wrapper before I knew ZF did:

stream_register_wrapper('zend.view', 'MyStream');

and in any views I just had to do:

<?=~ $this->foo; ?>

Of course, it introduced a non-standard php tag in to the views, but it
was OK in this instance because 1) it was just an experiment, and 2) the
code was for wholly in-house applications and none of it distributed, so
I didn't really have to worry about compatibility, short tags,
non-standard php tags, etc. But it did work like a charm!

Andy

Re: [fw-mvc] Auto HTML escaper module for Zend_View.

-- chikaram <chikara.miyake@gmail.com> wrote
(on Friday, 29 October 2010, 06:23 AM -0700):
> I love ZendFramework and I wanted my team use it.
> But that you couldn't escape vars in view automatically was its biggest
> drawbacks.
>
> So I write this - auto HTML escaper module for Zend_View:
> http://github.com/chikaram/gnix-view

You may be interested in work I've been doing on Zend\View in ZF2. In
that component, I'm separating variable storage into a separate object
-- which makes auto-escaping trivial:

echo $this->vars('foo'); // escaped
echo $this->vars()->getRawValue('foo'); // unescaped

It's also configurable, allowing you to disable auto-escaping if a
particular context does not require it:

$this->vars()->setIsStrict(false);
echo $this->vars('foo'); // unescaped

In ZF1, the only way to do auto-escaping requires extending Zend_View
and doing some hackery in __get and getVars (and optionally __set).
While it's do-able, it's non-trivial.

> It's been working well on a medium-scale project - about 45,000SLOC, 900M
> PVs/Month.
> We are very happy because we don't need to bother with writing
> $this->escape() all the time we use view variables.
>
> If you are interested, please use it and let me know how you feel.

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

[fw-auth] Re: Invalid baseDn error

I found the problem, it was a PICNIC (Problem In Chair, Not In Code) error :-) My LDAP server was expecting a DN in the form of "cn=Henry M Umansky (humansky@Princeton.EDU),o=Princeton University,c=US" whereas I was passing it just "humansky". I had to add the 'bindRequiresDn' => true option the LDAP options to make this happen.

-Henry

On Oct 28, 2010, at 9:23 PM, Henry Umansky wrote:

> Hello all,
> Zend Framework throws an exception when I use Zend_Auth to authenticate to LDAP when it contains a space in the baseDn. Did anyone else run into this problem?
>
> Here is my LDAP config (ini) options:
>
> [ldap]
> params.host = ldap.princeton.edu
> params.port = 389
> params.baseDn = "o=Princeton University,c=US"
> params.accountCanonicalForm = 2
>
> And here is a partial backtrace:
>
> [0] => An unexpected failure occurred
> [1] => 0x22 (Invalid DN syntax; Invalid DN): humansky
> [2] => host=ldap.princeton.edu,baseDn=o=Princeton University,c=US
> [3] => /Users/humansky/Projects/Novus/library/Zend/Ldap.php(899): 0x22 (Invalid DN syntax; Invalid DN): humansky
> [4] => #0 /Users/humansky/Projects/Novus/library/Zend/Auth/Adapter/Ldap.php(316): Zend_Ldap->bind('humansky', '*****')
> ....
>
> I know this baseDn works, because I've used it a number of times for other various applications and right before I submitted this email, I verified it worked with Ldapper desktop app. Before I submit a bug report, I want to make sure it's not something I'm doing wrong in my INI syntax.
>
> Thank you,
> Henry

Re: [fw-mvc] Auto HTML escaper module for Zend_View.

On Oct 29, 2010, at 9:23 AM, chikaram wrote:

>
> Hi everyone,
>
> I love ZendFramework and I wanted my team use it.
> But that you couldn't escape vars in view automatically was its biggest
> drawbacks.
>
> So I write this - auto HTML escaper module for Zend_View:
> http://github.com/chikaram/gnix-view
>
>
> It's been working well on a medium-scale project - about 45,000SLOC, 900M
> PVs/Month.
> We are very happy because we don't need to bother with writing
> $this->escape() all the time we use view variables.
>
> If you are interested, please use it and let me know how you feel.
>
> Regards,
>
> Chikaram
> http://twitter.com/chikaram
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/Auto-HTML-escaper-module-for-Zend-View-tp3019090p3019090.html
> Sent from the Zend MVC mailing list archive at Nabble.com.

I for one, don't always output to HTML, so automatically escaping for HTML would break my code. Plus, I'm sure the overheard for automatically parsing the whole view file in order to escape HTML entities would be a bit much.

-Henry

[fw-mvc] Auto HTML escaper module for Zend_View.

Hi everyone,

I love ZendFramework and I wanted my team use it.
But that you couldn't escape vars in view automatically was its biggest
drawbacks.

So I write this - auto HTML escaper module for Zend_View:
http://github.com/chikaram/gnix-view


It's been working well on a medium-scale project - about 45,000SLOC, 900M
PVs/Month.
We are very happy because we don't need to bother with writing
$this->escape() all the time we use view variables.

If you are interested, please use it and let me know how you feel.

Regards,

Chikaram
http://twitter.com/chikaram

--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Auto-HTML-escaper-module-for-Zend-View-tp3019090p3019090.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-db] need help with update

Hello Steve,
the problem is that your model code is missing.
Perhaps the parameter $where in the Model Object
($model->update($data,$where)) is not recognized.

reagrds
Tobias Neumann


2010/10/29 Steve Rayner <SRayner@williams-refrigeration.co.uk>:
> In my controller I have the following action;
>
> function editqtyAction()
> {
> // Dissable view and layout.
>      $this->_helper->viewRenderer->setNoRender();
>      $this->_helper->layout()->disableLayout();
>
>      if ($this->_request->isPost()) {
>
>            // Get the parameters from request and store in an array.
>            $nest_components_id = $this->_request->getPost('nest_components_id');
>            $qty = $this->_request->getPost('qty');
>            $data = array('qty' => $qty);
>
>            // Push to the database.
>            $model = new Titanium_Model_NestComponents;
>            $where = 'nest_components_id = ' . $nest_components_id;
>            $id = $model->update($data, $where);
>            echo(qty);
>      }
> }
>
> However, I get a 500 internal server error. From the stack trace I can see the SQL generated is;
>
> "UPDATE `nest_components` SET `qty` = ?, `modified_date` = ?, `modified_by_id` = ? WHERE (id=)"
>
> So it looks like the WHERE clause is incorrect. I don't understand where the (id=) part is coming from, and why has it not used the where clause I specified?
>
>
> Steve
>
>
>
> ________________________________
> -
> Williams Refrigeration is a trading name of AFE Group Limited.
> Registered in England & Wales under Registered Number 3872673. Registered
> Office Address - Bryggen Road, North Lynn, Industrial Estate, Kings Lynn, Norfolk, PE30 2HZ
>
> Williams Refrigeration filters email attachments for spam and viruses and malicious content with Sophos Puremessage. While every care has been made to ensure that this message is secure and virus free, we cannot be held responsible for any damage arising from computer viruses and advise that you perform your own checks on this and any other inbound messages.
>
> This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error or are having trouble sending email to us please notify the system administrator - postmaster@williams-refrigeration.co.uk
>
> Any views or opinions expressed in this e-mail are those of the sender and do not necessarily coincide with those of Williams Refrigeration or the AFE Group.
>

Re: [fw-db] need help with update

on 29/10/2010 11:55, Steve Rayner at SRayner@williams-refrigeration.co.uk
wrote:

> In my controller I have the following action;
>
> function editqtyAction()
> {
> // Dissable view and layout.
> $this->_helper->viewRenderer->setNoRender();
> $this->_helper->layout()->disableLayout();
>
> if ($this->_request->isPost()) {
>
> // Get the parameters from request and store in an array.
> $nest_components_id =
> $this->_request->getPost('nest_components_id');
> $qty = $this->_request->getPost('qty');
> $data = array('qty' => $qty);
>
> // Push to the database.
> $model = new Titanium_Model_NestComponents;
> $where = 'nest_components_id = ' . $nest_components_id;
> $id = $model->update($data, $where);
> echo(qty);
> }
> }
>
> However, I get a 500 internal server error. From the stack trace I can see the
> SQL generated is;
>
> "UPDATE `nest_components` SET `qty` = ?, `modified_date` = ?, `modified_by_id`
> = ? WHERE (id=)"
>
> So it looks like the WHERE clause is incorrect. I don't understand where the
> (id=) part is coming from, and why has it not used the where clause I
> specified?
>
>
> Steve
>

Steve,

Hi. You might want to re-write part of this to something like this I think,
which might work:

$where = $model->getAdapter()->quoteInto('nest_components_id = ?',
$nest_components_id);
$numOfRowsUpdated = $model->update($data, $where);

Note that the result from $model->update is not a $id as you've written but
rather how many rows were updated by the query.

Also, FYI, if your model is extending Zend_Db_Table_Abstract and
nest_components_id is your primary key on the NestComponents table then you
may find it to declare your own primary key in your sub-class by over-riding
$_primary, thus:

protected $_primary = 'nest_components_id';

otherwise the default 'id' is assumed to be the primary key (I think).

Regards,

Narinder.
--

______________________________________________________
| Narinder Chandi, Director,
| ToolBox Systems Limited, Surrey, England, UK.
| tel : +44 (0)1372 720117, mob : +44 (0)7973 512495
| www : http://www.toolbox.uk.com
| Skype : NarinderChandi
| LinkedIn : http://www.linkedin.com/in/toolboxsystems
| Twitter : @ToolBoxSystems
|______________________________________________________
| Consultancy * Development * Support
|______________________________________________________

[fw-db] need help with update

In my controller I have the following action;

function editqtyAction()
{
// Dissable view and layout.
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout()->disableLayout();

if ($this->_request->isPost()) {

// Get the parameters from request and store in an array.
$nest_components_id = $this->_request->getPost('nest_components_id');
$qty = $this->_request->getPost('qty');
$data = array('qty' => $qty);

// Push to the database.
$model = new Titanium_Model_NestComponents;
$where = 'nest_components_id = ' . $nest_components_id;
$id = $model->update($data, $where);
echo(qty);
}
}

However, I get a 500 internal server error. From the stack trace I can see the SQL generated is;

"UPDATE `nest_components` SET `qty` = ?, `modified_date` = ?, `modified_by_id` = ? WHERE (id=)"

So it looks like the WHERE clause is incorrect. I don't understand where the (id=) part is coming from, and why has it not used the where clause I specified?


Steve

________________________________
-
Williams Refrigeration is a trading name of AFE Group Limited.
Registered in England & Wales under Registered Number 3872673. Registered
Office Address - Bryggen Road, North Lynn, Industrial Estate, Kings Lynn, Norfolk, PE30 2HZ

Williams Refrigeration filters email attachments for spam and viruses and malicious content with Sophos Puremessage. While every care has been made to ensure that this message is secure and virus free, we cannot be held responsible for any damage arising from computer viruses and advise that you perform your own checks on this and any other inbound messages.

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error or are having trouble sending email to us please notify the system administrator - postmaster@williams-refrigeration.co.uk

Any views or opinions expressed in this e-mail are those of the sender and do not necessarily coincide with those of Williams Refrigeration or the AFE Group.

2010年10月28日星期四

[fw-auth] Invalid baseDn error

Hello all,
Zend Framework throws an exception when I use Zend_Auth to authenticate to LDAP when it contains a space in the baseDn. Did anyone else run into this problem?

Here is my LDAP config (ini) options:

[ldap]
params.host = ldap.princeton.edu
params.port = 389
params.baseDn = "o=Princeton University,c=US"
params.accountCanonicalForm = 2

And here is a partial backtrace:

[0] => An unexpected failure occurred
[1] => 0x22 (Invalid DN syntax; Invalid DN): humansky
[2] => host=ldap.princeton.edu,baseDn=o=Princeton University,c=US
[3] => /Users/humansky/Projects/Novus/library/Zend/Ldap.php(899): 0x22 (Invalid DN syntax; Invalid DN): humansky
[4] => #0 /Users/humansky/Projects/Novus/library/Zend/Auth/Adapter/Ldap.php(316): Zend_Ldap->bind('humansky', '*****')
....

I know this baseDn works, because I've used it a number of times for other various applications and right before I submitted this email, I verified it worked with Ldapper desktop app. Before I submit a bug report, I want to make sure it's not something I'm doing wrong in my INI syntax.

Thank you,
Henry

Re: [fw-db] findDependentRowset sorting issues

Zend_Db_Table_Row_Abstract#findDependentRowset() allows you to pass in a
select object as the third argument. It's been a while since I've used
Zend_Db but I believe it's something like this:

$select = $dependentTable->select();
$select->sort('some_field');
$row = $table->find(123);
$dependentRowset = $row->findDependentRowset($dependentTable, null,
$select);

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Wed, Oct 27, 2010 at 11:26 PM, Kumar Sekhar <kumar_sekhar@hotmail.com>wrote:

>
> I am using findDependentRowset(). I get my Rowset back but I need to sort
> the
> results by one of the columns in the dependent table. How can I do that?
> Please help !!
>
>
> In my project, I am working with Orders and their attending events. There
> is
> a one to many relationship between order and events. One order can have
> many
> events applied but a event belongs to only one order. I have the following
> database tables and classes (stripped down for the sake of this example):
>
>
>
> CREATE TABLE IF NOT EXISTS `bbcms_order` ( `oid` int(11) NOT NULL
> auto_increment, `salutation` varchar(10) NOT NULL, `fname` varchar(100) NOT
> NULL, `lname` varchar(100) NOT NULL, `mname` varchar(100) NOT NULL,
> `address` text NOT NULL, `postcode` varchar(10) NOT NULL, `plaats` int(5)
> NOT NULL, `telefoon` varchar(15) NOT NULL, `email` varchar(200) NOT NULL,
> `newsletter_optin` char(1) NOT NULL default '0', `membership_no`
> varchar(10)
> NOT NULL, `offline_sent` char(1) NOT NULL default '0', `order_total`
> varchar(10) NOT NULL, `order_status` char(1) NOT NULL, `status` char(1) NOT
> NULL default '1', PRIMARY KEY (`oid`) ) ENGINE=InnoDB DEFAULT
> CHARSET=latin1
> COMMENT='Order Master Table' AUTO_INCREMENT=7 ;
>
>
>
> CREATE TABLE IF NOT EXISTS `bbcms_order_event_data` ( `id` int(11) NOT NULL
> auto_increment, `order_id` int(11) NOT NULL, `event_id` int(11) NOT NULL,
> `timeslot_id` int(11) NOT NULL, `attending_person` int(3) NOT NULL,
> `event_status` char(2) NOT NULL, PRIMARY KEY (`id`), KEY `order_id`
> (`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;
>
>
> Regards,
> Kumar Sekhar
>
>
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/findDependentRowset-sorting-issues-tp3016667p3016667.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>

Re: [fw-mvc] Forms and HTML

I absolutely agree with David here. Decorators are technically well
designed and fine... but they are sometimes just a way too heavy
weapon for a small view level bells and whistles. At least for my
taste.

m.

On Tue, Oct 26, 2010 at 3:45 PM, David Mintz <david@davidmintz.org> wrote:
> It may be sacriligious to those who really love to do everything
> programmatically, but I think there is a lot to be said for going a sort of
> Middle Way and writing view scripts that render Zend_Form elements
> semi-manually, as it were. I sometimes do things like the following. It
> might be ugly, but it saves me from the torture of mastering all the nuances
> of decorators etc and gets the job done:
>
> <dl>
> <?= $I->mobile?>
> <?= $I->home ?>
> <?= $I->fax?>
> <?= $P->office_phone->renderLabel()?>
> <dd><?= $P->office_phone->renderViewHelper()?><?php if
> ($P->office_phone_ext) : ?>
> <?=$this->formLabel('person_office_phone_ext','Ext')?> <?=
> $P->office_phone_ext->renderViewHelper()?><?php endif; ?></dd>
> <?= $I->address1?>
> <?= $I->address2?>
> <dt>City</dt>
> <dd><?= $I->city->renderViewHelper()?> State <?=
> $I->state->renderViewHelper()?></dd>
> <?= $I->zip?>
> </dl>
>
> 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
>
>
> --
> David Mintz
> http://davidmintz.org/
> It ain't over:
> http://www.healthcare-now.org/
>

2010年10月27日星期三

[fw-db] findDependentRowset sorting issues

I am using findDependentRowset(). I get my Rowset back but I need to sort the
results by one of the columns in the dependent table. How can I do that?
Please help !!

In my project, I am working with Orders and their attending events. There is
a one to many relationship between order and events. One order can have many
events applied but a event belongs to only one order. I have the following
database tables and classes (stripped down for the sake of this example):

CREATE TABLE IF NOT EXISTS `bbcms_order` ( `oid` int(11) NOT NULL
auto_increment, `salutation` varchar(10) NOT NULL, `fname` varchar(100) NOT
NULL, `lname` varchar(100) NOT NULL, `mname` varchar(100) NOT NULL,
`address` text NOT NULL, `postcode` varchar(10) NOT NULL, `plaats` int(5)
NOT NULL, `telefoon` varchar(15) NOT NULL, `email` varchar(200) NOT NULL,
`newsletter_optin` char(1) NOT NULL default '0', `membership_no` varchar(10)
NOT NULL, `offline_sent` char(1) NOT NULL default '0', `order_total`
varchar(10) NOT NULL, `order_status` char(1) NOT NULL, `status` char(1) NOT
NULL default '1', PRIMARY KEY (`oid`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1
COMMENT='Order Master Table' AUTO_INCREMENT=7 ;

CREATE TABLE IF NOT EXISTS `bbcms_order_event_data` ( `id` int(11) NOT NULL
auto_increment, `order_id` int(11) NOT NULL, `event_id` int(11) NOT NULL,
`timeslot_id` int(11) NOT NULL, `attending_person` int(3) NOT NULL,
`event_status` char(2) NOT NULL, PRIMARY KEY (`id`), KEY `order_id`
(`order_id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;


Regards,
Kumar Sekhar


--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/findDependentRowset-sorting-issues-tp3016667p3016667.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-mvc] Re: Forms and HTML

Thomas,

I'm having the same problem. I cannot use 'escape' => false when using
addElement the way you are using it. Instead, I'm doing the following:

$emailElement = new Zend_Form_Element_Text('email');
$emailElement -> setLabel('*Your email address:')
-> setRequired(true)
-> setValidators(array('EmailAddress'))
-> setFilters(array('StringTrim'))
-> setDescription('')
-> setDecorators(array(
'ViewHelper',
array('Description', array('escape' => false, 'tag' => false)),
array('HtmlTag', array('tag' => 'dd')),
array('Label', array('tag' => 'dt', 'escape' => false)),
'Errors',
));
$this->addElement($emailElement);


I'm very new to this, so I'm sure that's not the most elegant solution, but
it seems to work.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Forms-and-HTML-tp3007790p3016637.html
Sent from the Zend MVC mailing list archive at Nabble.com.

[fw-db] Re: DB Profiler

Hello,

This post is very interesting.
I am using the Db_Profiler within the plugins, as indicated. Results are
shown each time the page is loaded. But when one runs through a ajax, does
not show any results. How or where I would use to examine Db_profiler
absolutely all queries are executed (insert, update, delete).
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/DB-Profiler-tp674034p3016627.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-db] DB Profiler

Hello, everyone.

I have read some very good post on Db_Profiler.
I'm using it in a Plugins to examine my consultations, obtaining the
expected results, every time you load the page. However, when queries are
run through a ajax, and the page does not refresh, not shown any results.
I wonder if anyone knows where or how to use the Db_Profiler to review
absolutely all my queries (insert, update, delete).

I welcome any comments, because I've been researching how to do it some time
and still not achieved eh.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/DB-Profiler-tp3016619p3016619.html
Sent from the Zend DB mailing list archive at Nabble.com.

Re: [fw-mvc] view scripts cont.

You probably have a layout configured (maybe in
/application/layouts/scripts).


On 27/10/2010 22:32, Thomas List wrote:
> I do not mean render. $this->view->results, in the controller that
> it was set up for in Zend 1.10, say MaineController, I can access the
> results in the /views/scripts/maine/index.phtml file...for example....
>
> From MaineController.php
>
> for($i=0; $i<sizeof($incentives); $i++){
>
>
> $ca = new Application_Model_IncentiveOutput();
> $incentiveOutput = new Application_Model_IncentiveOutputMapper();
> $resultsAdmin[] = $incentiveOutput->find($incentives[$i], $ca);
>
> }
> $request = $this->getRequest();
> $this->view->assign('zipCode', $request->getParam('zipCode'));
> $this->view->resultsAdmin = $resultsAdmin;
>
> in /views/scripts/maine/index.phtml
>
> <?php foreach($this->resultsAdmin as $incentive) :?>
> <?php echo $this->escape($incentive->offeredBy);?>....
>
> my question is why is do I have extra HTML at the beginning of the index.phtml file
> ex.
> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
> <head>
> <!-- the page title will be set within the actions -->
> <title>Housing Incentives</title> </head>
> <body>
>
> -thomas

[fw-mvc] view scripts cont.

I do not mean render. $this->view->results, in the controller that
it was set up for in Zend 1.10, say MaineController, I can access the
results in the /views/scripts/maine/index.phtml file...for example....

>From MaineController.php

for($i=0; $i<sizeof($incentives); $i++){


$ca = new Application_Model_IncentiveOutput();
$incentiveOutput = new Application_Model_IncentiveOutputMapper();
$resultsAdmin[] = $incentiveOutput->find($incentives[$i], $ca);

}
$request = $this->getRequest();
$this->view->assign('zipCode', $request->getParam('zipCode'));
$this->view->resultsAdmin = $resultsAdmin;

in /views/scripts/maine/index.phtml

<?php foreach($this->resultsAdmin as $incentive) :?>
<?php echo $this->escape($incentive->offeredBy);?>....

my question is why is do I have extra HTML at the beginning of the index.phtml file
ex.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<!-- the page title will be set within the actions -->
<title>Housing Incentives</title> </head>
<body>

-thomas

Re: [fw-mvc] view scripts

$this->view->result is not part of ZF... do you mean render?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Wed, Oct 27, 2010 at 2:08 PM, Thomas List <thomaslist@hotmail.com> wrote:

>
> Hello,
>
> I was looking at my page source for a view script which was rendered by a
> controller using $this->view->result, when I noticed that it has HTML in it,
> which I guess is rendered when you use $this->view? Am I correct? I am
> wondering how to get rid of this extraneous code, because it is throwing off
> my own HTML and CSS. It doesn't show up in the editor, only when I view
> source, so I am assuming it is rendered by the $this->view call in the
> controller. Any help would be great.
>
> Regards,
> Thomas
>

[fw-mvc] view scripts

Hello,

I was looking at my page source for a view script which was rendered by a controller using $this->view->result, when I noticed that it has HTML in it, which I guess is rendered when you use $this->view? Am I correct? I am wondering how to get rid of this extraneous code, because it is throwing off my own HTML and CSS. It doesn't show up in the editor, only when I view source, so I am assuming it is rendered by the $this->view call in the controller. Any help would be great.

Regards,
Thomas

Re: [fw-mvc] Re: Referer

Yeah please send a pastie

On 26 okt. 2010, at 01:09, Hector Virgen <djvirgen@gmail.com> wrote:

> Thanks for the tip, Wil. A pastie would be nice (your plane has wi-fi,
> right?) :)
>
> Does your solution cover the use case where a user enters in the wrong
> password on the first attempt but gets it right on the second attempt (or
> later)?
>
> --
> *Hector Virgen*
> Sr. Web Developer
> Walt Disney Parks and Resorts Online
> http://www.virgentech.com

Re: [fw-mvc] Forms and HTML

-- Andreas Möller <am@localheinz.com> wrote
(on Wednesday, 27 October 2010, 10:14 AM +0200):
> Sure - it might get the job done, but since you're not following Zend
> Framework Code Conventions, I wouldn't even bother considering to hire
> you if I were the owner of a company that is looking for a developer.

Please, try to keep the comments constructive. Comments like the one
above do nothing to aid the person asking the original question, and
instead polarize the discussion. Sure, the code sample may have used
short tags -- but ZF recommended short tags in view scripts for quite
some time. And, again, this was a _view_ script -- markup generally
follows very different rules than library or application code.
Additionally, different organizations and projects will have their own
requirements for coding standards -- regardless of our own personal
opinions on the matter, it's best to simply evaluate the code, and give
pointers for areas of improvement in the _logic_.

Again, if you have nothing constructive to add to a discussion, please
refrain from posting.

--
Matthew Weier O'Phinney
Project Lead | matthew@zend.com
Zend Framework | http://framework.zend.com/
PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc

Re: [fw-mvc] Re: Forms and HTML

> Way to go on missing the point.
>
> Something tells me that he has no interest at all in being hired by you. I
> don't think I would either. Last thing I would want would be a client
> telling me what coding style to use for code I write for other people...

Right, but writing quality code or not can make the difference between having clients at all - or not.


Best regards,

Andreas

[fw-mvc] Re: Forms and HTML

Way to go on missing the point.

Something tells me that he has no interest at all in being hired by you. I
don't think I would either. Last thing I would want would be a client
telling me what coding style to use for code I write for other people...

Cheers,
David
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Forms-and-HTML-tp3007790p3015368.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Re: charset utf-8 and accented characters

Since we are on the topic of UTF-8 and for anyone stumbling across
this again, I have a tiny checklist for UTF-8:

- Is your editor UTF-8?
- Meta tag in HTML set to UTF-8?
- Database/table/fields set to UTF-8?
- Database connection(!!!) set to UTF-8?

Especially the last one I ran into the past 2 years a few times, where
the connection was not properly UTF-8 and all hell broke lose.

And if you want to try Zend Studio, there is a free trial, but also
there is the PDT which is almost the same.

On Wed, Oct 27, 2010 at 10:11 AM, Andreas Möller <am@localheinz.com> wrote:
> Hello vanbom,
>
>
>> thank you Chris Riesen, that was the cause of the error. I dreamweaver:
>> preferences / new document / default encoding, so I change the encoding and
>> I get as well.
>
> consider using a real IDE - there are some out there that are good, while there are others that are excellent and boost productivity.
>
> Since having started to work with Zend Studio, there's no turning back.
>
>
> Best regards,
>
> Andreas
>

--
Greetings,
Christian Riesen
http://christianriesen.com/ - My personal page
http://toreas.com/ - Toreas a free fantasy novel
http://gamewiki.net/ - Open Videogames Wiki

Re: [fw-mvc] Forms and HTML

Hello David,


> It may be sacriligious to those who really love to do everything
> programmatically, but I think there is a lot to be said for going a sort of
> Middle Way and writing view scripts that render Zend_Form elements
> semi-manually, as it were. I sometimes do things like the following. It
> might be ugly, but it saves me from the torture of mastering all the nuances
> of decorators etc and gets the job done:
>
> <dl>
> <?= $I->mobile?>
> <?= $I->home ?>
> <?= $I->fax?>
> <?= $P->office_phone->renderLabel()?>
> <dd><?= $P->office_phone->renderViewHelper()?><?php if
> ($P->office_phone_ext) : ?>
> <?=$this->formLabel('person_office_phone_ext','Ext')?> <?=
> $P->office_phone_ext->renderViewHelper()?><?php endif; ?></dd>
> <?= $I->address1?>
> <?= $I->address2?>
> <dt>City</dt>
> <dd><?= $I->city->renderViewHelper()?> State <?=
> $I->state->renderViewHelper()?></dd>
> <?= $I->zip?>
> </dl>

Sure - it might get the job done, but since you're not following Zend Framework Code Conventions, I wouldn't even bother considering to hire you if I were the owner of a company that is looking for a developer.


Best regards,

Andreas

Re: [fw-mvc] Re: charset utf-8 and accented characters

Hello vanbom,


> thank you Chris Riesen, that was the cause of the error. I dreamweaver:
> preferences / new document / default encoding, so I change the encoding and
> I get as well.

consider using a real IDE - there are some out there that are good, while there are others that are excellent and boost productivity.

Since having started to work with Zend Studio, there's no turning back.


Best regards,

Andreas

Re: [fw-mvc] Forms and HTML

Hello Thomas,


> Thanks for your advice, although I'm sure that my presentation is separate from my "structure". Anyway, I figured it out, and it works very well now, thank you. Again, thank you for your help.

Even if you're sure, it's not. Take a look at this:

> > > $this->addElement('select','types', array(
> > > 'label' => '<span>font: 14pt Frutiger LT Std;color:#00B3FF;><b>What type of home do you live in:</b></span><br/>',

What do you see there? Markup that's neither semantic nor valid.

Recommended read: Zeldman, J., Designing with Web Standards, New Riders.


Best regards,

Andreas

2010年10月26日星期二

[fw-mvc] Re: Testing exceptions thrown by controllers

Hector Virgen <djvirgen@gmail.com> writes:

> On Tue, Oct 26, 2010 at 9:01 PM, K. Adam Christensen
> <pope@shifteleven.com>wrote:
>
>>
>> I know it's customary for controller unit tests to use the dispatch
>> method, but I think using dispatch goes against writing a unit test.
>> When you use dispatch, you're writing more of an integration test
>> because you end up running though your whole application stack, from
>> bootstrap to front controller and view initialization to finally your
>> controller.
>
>
> As I mentioned the bigger problem is when an exception is unexpectedly
> thrown by a controller. For example, let's say I have a test that verifies
> my login page shows a login form:
>
> public function testLoginPageShowsLoginForm()
> {
> $this->dispatch('login');
> $this->assertQuery('form#login');
> }
>
> If for some reason an exception is thrown, PHPUnit will say "Failed
> asserting node DENOTED BY form#login exists". Unfortunately that message is
> not very useful and I'm left without a clue as to what went wrong. When it
> comes to tests, seeing that exception stack trace is very useful.
>
> If I disable the error handler plugin, the situation is worse -- I'll see a
> message like "Zend_Dom_Exception: Cannot query, no document registered".
>
> Are there any workarounds to providing useful error messages when a
> controller test goes bad?

I totally get why this not reporting the error can be frustrating
because the error message is stuck within the response object; but I
think this better aids what I was saying about creating a UNIT test and
not an INTEGRATION test.

The unit test should help find those nasty exceptions that could pop up
here and there and let you just test the controller as a single unit. I
like leaving the integration tests for selenium/jbehave/cucumber since
that works your browser along with the full server stack.

That's my two cents on the matter

>
>>
>> If you check Zend_Test_PHPUnit_ControllerTestCase.php, you will see that
>> in the dispatch method there (as I am assuming that you're using this
>> method and that your test cases extend from this) that said method sets
>> throwExceptions to true. That appears to be why your settings aren't
>> sticking.
>>
>>
> Thanks, this explains it! I was about to burst a blood vessel in my left eye
> trying to find out why my setting wasn't sticking. Is there a reason why
> exceptions are not allowed to be thrown in controller tests?

Yeah, no idea. It seems kind of weird that it would be set in the
dispatch and not be respected by the test author.

- Adam

Re: [fw-mvc] Re: Testing exceptions thrown by controllers

On Tue, Oct 26, 2010 at 9:01 PM, K. Adam Christensen
<pope@shifteleven.com>wrote:

>
> I know it's customary for controller unit tests to use the dispatch
> method, but I think using dispatch goes against writing a unit test.
> When you use dispatch, you're writing more of an integration test
> because you end up running though your whole application stack, from
> bootstrap to front controller and view initialization to finally your
> controller.


As I mentioned the bigger problem is when an exception is unexpectedly
thrown by a controller. For example, let's say I have a test that verifies
my login page shows a login form:

public function testLoginPageShowsLoginForm()
{
$this->dispatch('login');
$this->assertQuery('form#login');
}

If for some reason an exception is thrown, PHPUnit will say "Failed
asserting node DENOTED BY form#login exists". Unfortunately that message is
not very useful and I'm left without a clue as to what went wrong. When it
comes to tests, seeing that exception stack trace is very useful.

If I disable the error handler plugin, the situation is worse -- I'll see a
message like "Zend_Dom_Exception: Cannot query, no document registered".

Are there any workarounds to providing useful error messages when a
controller test goes bad?


>
> If you check Zend_Test_PHPUnit_ControllerTestCase.php, you will see that
> in the dispatch method there (as I am assuming that you're using this
> method and that your test cases extend from this) that said method sets
> throwExceptions to true. That appears to be why your settings aren't
> sticking.
>
>
Thanks, this explains it! I was about to burst a blood vessel in my left eye
trying to find out why my setting wasn't sticking. Is there a reason why
exceptions are not allowed to be thrown in controller tests?

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

[fw-mvc] Re: Testing exceptions thrown by controllers

pope@shifteleven.com (K. Adam Christensen)
writes:

> If you check Zend_Test_PHPUnit_ControllerTestCase.php, you will see
> that in the dispatch method there (as I am assuming that you're using
> this method and that your test cases extend from this) that said
> method sets throwExceptions to true. That appears to be why your
> settings aren't sticking.

I mean to say that it sets throwExceptions to FALSE in the dispatch
method of the controller test case.

- Adam

[fw-mvc] Re: Testing exceptions thrown by controllers

Hi Hector,

Hector Virgen <djvirgen@gmail.com> writes:

> I am unit testing my controllers using Zend_Test and am having trouble
> testing exceptions thrown by action methods. Here's my test:
>
> /**
> * @expectedException My_Exception
> public function testExpectedException()
> {
> $this->dispatch('page/that/should/throw/exception');
> }

I know it's customary for controller unit tests to use the dispatch
method, but I think using dispatch goes against writing a unit test.
When you use dispatch, you're writing more of an integration test
because you end up running though your whole application stack, from
bootstrap to front controller and view initialization to finally your
controller.

If you would like to test that this exception is being thrown, perhaps
isolate your controller and treat it like a simple object

/**
* @expectedException My_Exception
*/
public function testExpectedException()
{
$controller = new YourController(
// You could also use PHPUnit mocks here
new Zend_Controller_Request_HttpTestCase(),
new Zend_Controller_Response_HttpTestCase()
);
$controller->exceptionAction();
}

> I've tried disabling the error handler plugin:
> $front->setParam('noErrorHandler', true);
>
> I've also tried enabling throwExceptions in the front controller:
> $front->throwExceptions(true);
>
> But it seems no matter what I do the exception is caught by the front
> controller and attached to the response object (and not rethrown).
>
> Technically, I could write my test like this:
>
> public function testExpectedException()
> {
> $this->dispatch('page/that/should/throw/exception');
> if (!$this->response->isException()) {
> $this->fail('expecting an exception!');
> }
> }

If you check Zend_Test_PHPUnit_ControllerTestCase.php, you will see that
in the dispatch method there (as I am assuming that you're using this
method and that your test cases extend from this) that said method sets
throwExceptions to true. That appears to be why your settings aren't sticking.

Cheers,
- K. Adam Christensen

Re: [fw-db] Large Zend_Form with many fields and processing it problem

It sounds like your form is handling too many responsibilities -- editing,
adding and removing data. If you break those tasks up into separate forms,
it should be easier to manage -- at least from within PHP.

Once you've broken those tasks up into smaller forms, I suggest adding some
fancy javascript to improve the UI -- the user doesn't have to know they're
manipulating multiple forms. The important thing is to make the backend work
with atomic commands (add director, edit actor, delete actor, etc.)

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

On Tue, Oct 26, 2010 at 11:06 AM, greg606 <greg606@gmail.com> wrote:

>
> Hi,
> I'm designing a really big Zend_Form and I have a few problems:
>
> I start by populating it with a model (a movie - data taken from 16
> database
> tables, about 5 of them are joining tables, at this point it doesn't matter
> as it's just a movie object) with many fields created by foreach loops.
> But I have no idea how to process such a big form.
> 1. Should check what data is updated? How? What then?
> 2. How to handle the case when I want to remove some data? Emptying fields
> manually is not comfortable.
>
> For now I begin with the simplest movie form with data from just one main
> table.
> But to my mind it won't be very well if I have to force user to move to
> other forms to edit directors or actors?
>
> I will be really grateful for advice on design complex forms and processing
> updates/adding to many tables.
>
> With regards,
> Greg
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Large-Zend-Form-with-many-fields-and-processing-it-problem-tp3014216p3014216.html
> Sent from the Zend DB mailing list archive at Nabble.com.
>
>

[fw-mvc] Testing exceptions thrown by controllers

Hello,

I am unit testing my controllers using Zend_Test and am having trouble
testing exceptions thrown by action methods. Here's my test:

/**
* @expectedException My_Exception
public function testExpectedException()
{
$this->dispatch('page/that/should/throw/exception');
}

And my action method:

public function exceptionAction()
{
throw new My_Exception('test!');
}

I've tried disabling the error handler plugin:
$front->setParam('noErrorHandler', true);

I've also tried enabling throwExceptions in the front controller:
$front->throwExceptions(true);

But it seems no matter what I do the exception is caught by the front
controller and attached to the response object (and not rethrown).

Technically, I could write my test like this:

public function testExpectedException()
{
$this->dispatch('page/that/should/throw/exception');
if (!$this->response->isException()) {
$this->fail('expecting an exception!');
}
}

But I don't like that because it doesn't follow the PHPUnit standard (I'd
like to use the @expectedException annotation).

The bigger problem is when an UNexpected exception is thrown by an action
method -- I'd like to see the stack trace to diagnose why the exception
occurred.

Is there something I'm missing? Thanks!

--
*Hector Virgen*
Sr. Web Developer
http://www.virgentech.com

[fw-db] Large Zend_Form with many fields and processing it problem

Hi,
I'm designing a really big Zend_Form and I have a few problems:

I start by populating it with a model (a movie - data taken from 16 database
tables, about 5 of them are joining tables, at this point it doesn't matter
as it's just a movie object) with many fields created by foreach loops.
But I have no idea how to process such a big form.
1. Should check what data is updated? How? What then?
2. How to handle the case when I want to remove some data? Emptying fields
manually is not comfortable.

For now I begin with the simplest movie form with data from just one main
table.
But to my mind it won't be very well if I have to force user to move to
other forms to edit directors or actors?

I will be really grateful for advice on design complex forms and processing
updates/adding to many tables.

With regards,
Greg
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Large-Zend-Form-with-many-fields-and-processing-it-problem-tp3014216p3014216.html
Sent from the Zend DB mailing list archive at Nabble.com.

[fw-mvc] Re: charset utf-8 and accented characters

thank you Chris Riesen, that was the cause of the error. I dreamweaver:
preferences / new document / default encoding, so I change the encoding and
I get as well.
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/charset-utf-8-and-accented-characters-tp3013294p3013939.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Forms and HTML

It may be sacriligious to those who really love to do everything
programmatically, but I think there is a lot to be said for going a sort of
Middle Way and writing view scripts that render Zend_Form elements
semi-manually, as it were. I sometimes do things like the following. It
might be ugly, but it saves me from the torture of mastering all the nuances
of decorators etc and gets the job done:

<dl>
<?= $I->mobile?>
<?= $I->home ?>
<?= $I->fax?>
<?= $P->office_phone->renderLabel()?>
<dd><?= $P->office_phone->renderViewHelper()?><?php if
($P->office_phone_ext) : ?>
<?=$this->formLabel('person_office_phone_ext','Ext')?> <?=
$P->office_phone_ext->renderViewHelper()?><?php endif; ?></dd>
<?= $I->address1?>
<?= $I->address2?>
<dt>City</dt>
<dd><?= $I->city->renderViewHelper()?> State <?=
$I->state->renderViewHelper()?></dd>
<?= $I->zip?>
</dl>

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


--
David Mintz
http://davidmintz.org/
It ain't over:
http://www.healthcare-now.org/

[fw-mvc] Navigation, Acl and AccessManager Action Plugin

I there:

I need to integrate Acl into Navigation, as in the manual:

$this->navigation()->setAcl($acl);

I'm using monzee AccessManager Action Plugin for the Access Control List:
http://code.google.com/p/mz-project/source/browse/trunk/modules/admin/controllers/helpers/AccessManager.php

This Action Helper build ACL based on the request, so no all resources are
loaded.
To load all resources I've to query my database about all record.

Is this Action Helper obsolete? (the project last update is on May 28,
2009).

How do you manage yours ACL?

Re: [fw-mvc] charset utf-8 and accented characters

A common mistake I see regarding this is that your editor is not set
to UTF-8, so you save as ISO-something while the browser expects
UTF-8. Check your settings. On Zend Studio it's in the preferences
under General / Workspace. You can also find it on a per project
basis, right click project, choose properties and there on the
resource part you can see Text file encoding for this specific
project.

On Tue, Oct 26, 2010 at 10:15 AM, vanbom <dro66_8@hotmail.fr> wrote:
>
> hello, I'm trying to redo my blog in zend framewrok 1.10. it starts well,
> controller, layout, view ....
> May I meet a worry that I do not understand.
> I use an overall layout for the site, and view each page to generate: Title,
> description, .... for each page.
>
> mon problème est que quand un Title ou une Description contient un caractère
> accentué , rien n'est afficher .
>
> codes :
>
> Applcation/bootstrap.php :
> $view->headMeta()->appendHttpEquiv("content-type","text/html;
> charset=utf-8");
>
> exemple :
>
> views\scripts\index\index.phtml
> <?php $this->headTitle()->append(" caractère accentué")?>
>
> application\layouts\scripts\layout.phtml
> <?php echo $this->headMeta();?>
>
> and when I request the page, I get the empty  .
>
> but,  if I change the "é" and " è" in "e" I get good title: caractere
> accentue
>
> thank you in advance for your answers
>
>
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/charset-utf-8-and-accented-characters-tp3013294p3013294.html
> Sent from the Zend MVC mailing list archive at Nabble.com.
>

--
Greetings,
Christian Riesen
http://christianriesen.com/ - My personal page
http://toreas.com/ - Toreas a free fantasy novel
http://gamewiki.net/ - Open Videogames Wiki

[fw-mvc] charset utf-8 and accented characters

hello, I'm trying to redo my blog in zend framewrok 1.10. it starts well,
controller, layout, view ....
May I meet a worry that I do not understand.
I use an overall layout for the site, and view each page to generate: Title,
description, .... for each page.

mon problème est que quand un Title ou une Description contient un caractère
accentué , rien n'est afficher .

codes :

Applcation/bootstrap.php :
$view->headMeta()->appendHttpEquiv("content-type","text/html;
charset=utf-8");

exemple :

views\scripts\index\index.phtml
<?php $this->headTitle()->append(" caractère accentué")?>

application\layouts\scripts\layout.phtml
<?php echo $this->headMeta();?>

and when I request the page, I get the empty .

but, if I change the "é" and " è" in "e" I get good title: caractere
accentue

thank you in advance for your answers


--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/charset-utf-8-and-accented-characters-tp3013294p3013294.html
Sent from the Zend MVC mailing list archive at Nabble.com.

2010年10月25日星期一

Re: [fw-mvc] Re: Referer

Thanks for the tip, Wil. A pastie would be nice (your plane has wi-fi,
right?) :)

Does your solution cover the use case where a user enters in the wrong
password on the first attempt but gets it right on the second attempt (or
later)?

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

[fw-mvc] Re: Referer

Some good ideas have been thrown out here...I have a slightly different
method which seems much simpler than utilizing Session. I'm about to board a
plane so I'll be brief. If you need code for a specific piece, post back and
I'll set you up:


1 - Write a front-controller plug-in and hook into routeShutdown
NOTE: I haven't seen any good reason to wait any longer than
routeShutdown (if anyone has contrary feedback, I'd be interested in knowing
about it)
2 - bail-out early if already logged in (return;)
3 - if the requested resource is not secured, bail-out (return;)
4 - switch the resource by manually setting module, controller, and action
5 - set a request parameter
Example: $request->setParam('onAuthenticateGoto',
$request->getPathInfo());
6 - return the request object


Good luck. Let me know if you need a pastie.

-----
--
Wil Moore III

Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/Referer-tp3007321p3012923.html
Sent from the Zend MVC mailing list archive at Nabble.com.

Re: [fw-mvc] Forms and HTML

Hello Thomas,

> I posted this last week, and I am still having a problem with getting HTML integrated with my form. I am setting the escape value to false, but it still doesn't seem to render the HTML for the label, for example, I have this element in my form:
>
> $this->addElement('select','types', array(
> 'label' => '<span>font: 14pt Frutiger LT Std;color:#00B3FF;><b>What type of home do you live in:</b></span><br/>',
> 'escape' => false,
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));
>
> I'm not quite sure what I am missing, but I can't seem to render HTML for the label. Is there something else I need to add to my form class?


From what I can see, you're missing some knowledge about (X)HTML and CSS in the first place. What you're attempting to do there - apart from the fact that your (X)HTML it won't validate, let alone that rarely anyone will have the font available - is not considered good practice (separate structure from presentation.

Maybe that's why your question remains unanswered.


Best regards,

Andreas

Re: [fw-mvc] Forms and HTML

Change your addElement to:

$this -> addElement( 'select', 'types', array(
'label' => '<span style="font: 14pt Frutiger LT Std; color: #00B3FF;"><b>What type of home do you live in:</b></span><br />',
'escape' => false,
'required' => true,
'multiOptions' => array(
'Existing Home' => 'Existing Home',
'New Construction' => 'New Construction',
'Condominium' => 'Condominium',
'Apartment' => 'Apartment'
),
'decorators' => array(
'ViewHelper',
'Errors',
array( 'HtmlTag', array( 'tag' => 'dd' ) ),
array( 'Label', array( 'tag' => 'dt', 'escape' => false) )
)
));

You can optionally leave out the "decorators" key from the options array and instead select the element from the form and manually alter the decorator:

$this -> getElement( 'types' ) -> getDecorator( 'Label' ) -> setOption( 'escape', false );

Ideally, you should be writing a separate label decorator and view
helper simply because you have so much HTML in your label attribute.
Look at the source code for the classes Zend_Form_Decorator_Label and
Zend_View_Helper_FormLabel and extend them so you can get what you need
without having to create an HTML headache with each element in your form.

Logan McGrath


On 10/25/2010 12:00 PM, Thomas List wrote:
> Helllo,
>
> I posted this last week, and I am still having a problem with getting HTML integrated with my form. I am setting the escape value to false, but it still doesn't seem to render the HTML for the label, for example, I have this element in my form:
>
> $this->addElement('select','types', array(
> 'label' => '<span>font: 14pt Frutiger LT Std;color:#00B3FF;><b>What type of home do you live in:</b></span><br/>',
> 'escape' => false,
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));
>
> I'm not quite sure what I am missing, but I can't seem to render HTML for the label. Is there something else I need to add to my form class?
>
> Thank You,
> Thomas List
>

Re: [fw-mvc] Forms and HTML

On 10/25/2010 1:00 PM, Thomas List wrote:
> Helllo,
>
> I posted this last week, and I am still having a problem with getting HTML integrated with my form. I am setting the escape value to false, but it still doesn't seem to render the HTML for the label, for example, I have this element in my form:
>
> $this->addElement('select','types', array(
> 'label' => '<span>font: 14pt Frutiger LT Std;color:#00B3FF;><b>What type of home do you live in:</b></span><br/>',
> 'escape' => false,
> 'required' => true,
> 'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));
>
> I'm not quite sure what I am missing, but I can't seem to render HTML for the label. Is there something else I need to add to my form class?
>
> Thank You,
> Thomas List
>

Thomas,

After the element has been added to the form, try the following:

$this->types->getDecorator('Label')->setOption('escape', false);

Rob

[fw-mvc] Forms and HTML

Helllo,

I posted this last week, and I am still having a problem with getting HTML integrated with my form. I am setting the escape value to false, but it still doesn't seem to render the HTML for the label, for example, I have this element in my form:

$this->addElement('select','types', array(
'label' => '<span>font: 14pt Frutiger LT Std;color:#00B3FF;><b>What type of home do you live in:</b></span><br/>',
'escape' => false,
'required' => true,
'multiOptions' => array( 'Existing Home' => 'Existing Home', 'New Construction' => 'New Construction', 'Condominium' => 'Condominium', 'Apartment' => 'Apartment',),));

I'm not quite sure what I am missing, but I can't seem to render HTML for the label. Is there something else I need to add to my form class?

Thank You,
Thomas List

Re: [fw-mvc] about Routes

Hi,

Little advice : every time you made a copy&paste action , you're doing
a wrong thing and you should find an other way.

Regards,


On Sat, 23 Oct 2010 10:03:58 -0500, Expertics <expertics@gmail.com>
wrote:
> Logan and Mon ,
>
> Thank you very much for your answers
>
> George
>
> El 22/10/10 23:22, Logan McGrath escribió:
>> 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.
>>

--
Jean-Sébastien H.
au-fil-du.net

Re: [fw-mvc] Referer

In the plugin's predispatch method you perform your check whether the current consumer has authenticated and has privileges for the desired action - if he doesn't, you save the requested url and either

a) modify the request object so the request will be dispatched to your login action

or

b) you redirect to the login action.


Best regards,

Andreas

Re: [fw-mvc] Referer

Right so where should i call my saveOriginalUrl

On Mon, Oct 25, 2010 at 10:52 AM, Andreas Möller <am@localheinz.com> wrote:

> That's what a plugin is supposed to be for.
>
>
> Best regards,
>
> Andreas
>
>


--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

Re: [fw-mvc] Referer

That's what a plugin is supposed to be for.


Best regards,

Andreas

Re: [fw-mvc] Referer

Hi,

Thanks for your reply.
But then I have to call it in each controller. shouldn't it be called in a
kind of pre-dispach loop?

On Mon, Oct 25, 2010 at 10:11 AM, Jean-Sébastien H.
<jeanseb@au-fil-du.net>wrote:

> Hi,
>
> You should call saveOriginalUrl before the redirection.
>
> PS : FlashMessenger action helper can help you to store the URL
>
>
> http://framework.zend.com/manual/en/zend.controller.actionhelpers.html#zend.controller.actionhelper.flashmessenger.introduction
>
> On Sun, 24 Oct 2010 09:52:51 +0200, Jigal sanders
> <jigalroecha@gmail.com> wrote:
> > Hello,
> >
> > With some help I have created the action helper below, but i don't know
> when
> > to call the saveOriginalUrl function:
> >
> >
>
>
> --
> Jean-Sébastien H.
> au-fil-du.net
>

--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

Re: [fw-mvc] Referer

Little push.

Any idea's?

On Sun, Oct 24, 2010 at 9:52 AM, Jigal sanders <jigalroecha@gmail.com>wrote:

> Hello,
>
> With some help I have created the action helper below, but i don't know
> when to call the saveOriginalUrl function:
>
>
> <?php
> class SF_Controller_Action_Helper_Referrer extends Zend_Controller_Action_Helper_Abstract
> {
> public function saveOriginalUrl(){
> $session = new Zend_Session_Namespace('login');
> $request = $this->getRequest();
> $session->goToAfterLogin = array(
> $request->getActionName(),
> $request->getControllerName(),
> $request->getModuleName(),
>
> );
> return $this->_getRedirect()->gotoSimple('login','user','eventManager');
> }
>
> public function getOriginalUrl(){
> $session = new Zend_Session_Namespace('login');
> if(isset($session->goToAfterLogin)){
> $gotoAfterLogin = $session->goToAfterLogin;
> unset($session->goToAfterLogin);
> return $this->_getRedirect->gotoSimple($gotoAfterLogin);
> }
> return $this->_getRedirect()->gotoUrl('/');
> }
>
> protected function _getRedirect(){
> return Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
> }
> }
>
>
> On Fri, Oct 22, 2010 at 7:12 PM, Hector Virgen <djvirgen@gmail.com> wrote:
>
>> 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
>>
>
>
>
> --
> Met vriendelijke groet,
>
> Jigal Sanders
> A.J. Ernststraat 739
> 1082 LK Amsterdam
> Mobiel: 06-42111489
>

--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

2010年10月24日星期日

Re: [fw-mvc] Referer

Hello,

With some help I have created the action helper below, but i don't know when
to call the saveOriginalUrl function:

<?php
class SF_Controller_Action_Helper_Referrer extends
Zend_Controller_Action_Helper_Abstract
{
public function saveOriginalUrl(){
$session = new Zend_Session_Namespace('login');
$request = $this->getRequest();
$session->goToAfterLogin = array(
$request->getActionName(),
$request->getControllerName(),
$request->getModuleName(),

);
return $this->_getRedirect()->gotoSimple('login','user','eventManager');
}

public function getOriginalUrl(){
$session = new Zend_Session_Namespace('login');
if(isset($session->goToAfterLogin)){
$gotoAfterLogin = $session->goToAfterLogin;
unset($session->goToAfterLogin);
return $this->_getRedirect->gotoSimple($gotoAfterLogin);
}
return $this->_getRedirect()->gotoUrl('/');
}

protected function _getRedirect(){
return Zend_Controller_Action_HelperBroker::getStaticHelper('Redirector');
}
}


On Fri, Oct 22, 2010 at 7:12 PM, Hector Virgen <djvirgen@gmail.com> wrote:

> 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
>

--
Met vriendelijke groet,

Jigal Sanders
A.J. Ernststraat 739
1082 LK Amsterdam
Mobiel: 06-42111489

2010年10月23日星期六

Re: [fw-mvc] about Routes

Logan and Mon ,

Thank you very much for your answers

George

El 22/10/10 23:22, Logan McGrath escribió:
> 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] 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