Re: [fw-general] [Zend_Form] Zend_Form_Element_File::getValue() is calling Zend_File_Transfer_Http:: receive()

2008-12-05 Thread Laurent Melmoux

see my comments below

Thomas Weidner a écrit :
When you are calling getValue or receive you are saying please move 
the file.
It would be nonsense to add a behaviour which does NOT move the file 
when you want to move the file.

Well I found it confusing the first time.

For me if I'm calling getValue I'm not expecting to have my data saved 
in a directory nor in the database.
With getValue I'm expecting just data and then see if I want to save 
them on not. If so I'm doing a insert/update on the database and call 
receive to save the file.
We could argue that if we call getValue, we are requesting data and with 
files data are the files them self ...


All this is very subjective, and I can switch my brain logic to work 
this way. A note in the manual about it could be good.




With the ZF you need the same amount of lines, 3,  as with your solution.
I don't see that this should be more complicated to call isUploaded 
than to fetch an exception.


if (!$form-file-receive() or !$form-file-isUploaded()) {
   rollback translation
}

you are right.


Btw: Your code does NOT change the name which means that is not 
representative. Therefor I did also compress my example to show the 
same behaviour as yours.
Now that I have a better understanding on how Zend_File_Transert all 
work with Zend_Form and how Zend_Filter_File_Remane work I'm find with 
all that. 


I was thinking of 2 naming strategies :

1) You are storing the name of the file in the db
here the current solution is perfect, you get the file name with 
getValue() ready to be saved in the db


2) You are NOT storing the name of the file in the db and named it base 
on the primary key value
lets say you have this naming scheme : pkValue__photo (1__photo1, 
1__photo2, ..., 56__photo1, 56__photo2)

so you call getValue() have the file stored
insert the data in the db, fetch the pk value with lastInsertedId()
and then reapply  the  Rename filter


Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - From: Laurent Melmoux [EMAIL PROTECTED]
To: Thomas Weidner [EMAIL PROTECTED]
Cc: Zend Framework General fw-general@lists.zend.com
Sent: Thursday, December 04, 2008 10:07 AM
Subject: Re: [fw-general] [Zend_Form] 
Zend_Form_Element_File::getValue() is calling 
Zend_File_Transfer_Http:: receive()




Thomas,

And what about a flag to switch off this behavior ?
I think leaving the developer decide when the save the files fit in 
the philosophy of the Zend Framework, in term of flexibility.


I agree there is several tricks to go around this but it make my code 
more complicated :(


Thomas Weidner a écrit :

Laurent,

I would say that the isReceived method is a really easy way to check 
this.
Or you can get the file infos and check for the isReceived tag 
manually.


You can delete all files which have been received until then without 
problems.


Changing the name can also easily be done by using the rename filter.

When you want to do the retrievment manually you can do this already 
with the existing implementation.

Simply use the old syntax instead of the new getValue syntax.
isValid - rename - receive

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - From: Laurent Melmoux [EMAIL PROTECTED]
To: Zend Framework General fw-general@lists.zend.com
Sent: Wednesday, December 03, 2008 7:04 PM
Subject: [fw-general] [Zend_Form] Zend_Form_Element_File::getValue() 
is calling Zend_File_Transfer_Http:: receive()




Hi,

I’m wondering if it is a good idea to move the uploaded file on 
Zend_Form_Element_File::getValue() call.


Because:

• If the receive() failed for what ever reason I may not want to go 
further like inserting the other data in the database. And 
Currently there is no easy way to check if receive() succeed.

• Or if a database transaction failed I will have to delete the files
• What if we want to name the file from the UID of the database record


Personally I prefer to use this pattern:

$this-db-beginTransaction();
try {

// will not call receive()
$data = $this-form-getValues(); $this-insert($data);
// will call Zend_File_Transfer_Http:: receive()
// if receive() failed throw an exception then no data is inserted
$this-saveFiles();
$this-db-commit();
} catch (Exception $ex) {
$this-db-rollBack();
}

Not calling receive() on Zend_Form_Element_File::getValue() would 
leave more flexibility for the developer on how he want to handle 
the file. What do you think?


--
Laurent Melmoux
Conseil et Solutions Web | [EMAIL PROTECTED]
2mx - Annecy, France | http://laurent.2mx.fr/






Re: [fw-general] [Zend_Form] Zend_Form_Element_File::getValue() is calling Zend_File_Transfer_Http:: receive()

2008-12-05 Thread Thomas Weidner

Hy,


I was thinking of 2 naming strategies :

1) You are storing the name of the file in the db
here the current solution is perfect, you get the file name with 
getValue() ready to be saved in the db


2) You are NOT storing the name of the file in the db and named it base on 
the primary key value
lets say you have this naming scheme : pkValue__photo (1__photo1, 
1__photo2, ..., 56__photo1, 56__photo2)

so you call getValue() have the file stored
insert the data in the db, fetch the pk value with lastInsertedId()
and then reapply  the  Rename filter


There is one big difference which is the problem in your assumption.
getValue does NOT return the filename it receives the file and makes several 
other data in background. The filename is not the value of the file element.


So the logical way in my opinion would be to call getFileName, change the 
name according to the primary key of the database by applying the rename 
filter, and then, as last step calling getValues().

If validation or anything other fails, revert db entry.
You could even validate before attaching the rename filter because 
validation does not receive the file.


if ($file-isValid()) {
   $file-getFileName();
   get id, rework filename
   $file-addFilter('rename', $newfilename);
 -getValues();
}

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com 



Re: [fw-general] Unit testing domain specific controllers

2008-12-05 Thread Giorgio Sironi
2008/12/4 Mary Nicole Hicks [EMAIL PROTECTED]


 Can anyone throw me some ideas on ways to unit test domain specific
 controllers. I have controllers that act slightly differently depending on
 the domain in the request and I also have some controllers that are only
 available on some domains.


For domain you intend an hostname or a specific model? However, Zend_Test is
the way to accomplish integration test on controllers.

-- 
Giorgio Sironi
Piccolo Principe  Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno


[fw-general] Bug? Weird timeouts with Zend_Session_SaveHandler_DbTable

2008-12-05 Thread Joachim Lous
Hi, I'm using Zend_Session with  Zend_Session_SaveHandler_DbTable,
but am encountering some problems

I have set it up exactly as the example in the docs prescribe, against
a mysql 5 db, and it mostly works.

But I can't control the session lifetime, no matter how I try.
I've tried ini files, Zend_Session::rememberMe() all over the place.
What ends up in the 'lifetime' column in the table is always
the same thing: 1440

And that is how it behaves too.  24 minutes without a request?
You're logged out.

Is it a bug? Am I missing something really obvious?
All help appreciated.

-Joachim.


Re: [fw-general] [Zend_Form] Zend_Form_Element_File::getValue() is calling Zend_File_Transfer_Http:: receive()

2008-12-05 Thread Laurent Melmoux

Laurent Melmoux a écrit :

Thomas,

my comment  :

Thomas Weidner a écrit :

Hy,


I was thinking of 2 naming strategies :

1) You are storing the name of the file in the db
here the current solution is perfect, you get the file name with 
getValue() ready to be saved in the db


2) You are NOT storing the name of the file in the db and named it 
base on the primary key value
lets say you have this naming scheme : pkValue__photo (1__photo1, 
1__photo2, ..., 56__photo1, 56__photo2)

so you call getValue() have the file stored
insert the data in the db, fetch the pk value with lastInsertedId()
and then reapply  the  Rename filter


There is one big difference which is the problem in your assumption.
getValue does NOT return the filename it receives the file and makes 
several other data in background. The filename is not the value of 
the file element.
Looking at Zend_Form_Element_File::getValue() we get the new filename 
after filter are apply. Am I wrong ?



if (!$this-receive()) {
 return null;
}
  $filename = basename($this-getFileName());
$this-_value = $filename;
return $filename;



So the logical way in my opinion would be to call getFileName, change 
the name according to the primary key of the database by applying the 
rename filter, and then, as last step calling getValues().
The problem here is that I have to call getValues() first to have the 
data save in the db and get the last Inserted Id

If validation or anything other fails, revert db entry.
You could even validate before attaching the rename filter because 
validation does not receive the file.


if ($file-isValid()) {
   $file-getFileName();
   get id, rework filename
   $file-addFilter('rename', $newfilename);
 -getValues();
}

I have tried something like below after a call to getValues() and 
getting the last Inserted Id  $uid
It is working all find except when my file is not require and it is send 
with the form.
I don't know where to check if the file have been send with the form or 
not. isReceived()  return true in both case photo (file attach or not to 
the form). May be there is a need for an other flag like  
$this-_files[$file]['submited'] ?



   $sourceName = $this-_form-getElement('photo')-getFileName();
   require_once 'Zend/Filter/File/Rename.php';
   $options = array(
   'source' = $sourceName ,
   'target' = $_SERVER['DOCUMENT_ROOT'] . 'medias/news/photos/' . 
$uid . '__photo' ,

   'overwrite' = true);
   $renameFileFilter = new Zend_Filter_File_Rename($options);
   $renameFileFilter-filter($sourceName);





Re: [fw-general] [Zend_Form] Zend_Form_Element_File::getValue() is calling Zend_File_Transfer_Http:: receive()

2008-12-05 Thread Laurent Melmoux

Oups ! Working good :)

Thomas Weidner a écrit :
According to the manual the isUploaded method checks if a file element 
has been uploaded or not.

See chapter 19.1.3

Greetings
Thomas Weidner, I18N Team Leader, Zend Framework
http://www.thomasweidner.com

- Original Message - From: Laurent Melmoux [EMAIL PROTECTED]
To: Zend Framework General fw-general@lists.zend.com
Cc: Thomas Weidner [EMAIL PROTECTED]
Sent: Friday, December 05, 2008 1:08 PM
Subject: Re: [fw-general] [Zend_Form] 
Zend_Form_Element_File::getValue() is calling 
Zend_File_Transfer_Http:: receive()




Laurent Melmoux a écrit :

Thomas,

my comment  :

Thomas Weidner a écrit :

Hy,


I was thinking of 2 naming strategies :

1) You are storing the name of the file in the db
here the current solution is perfect, you get the file name with 
getValue() ready to be saved in the db


2) You are NOT storing the name of the file in the db and named it 
base on the primary key value
lets say you have this naming scheme : pkValue__photo (1__photo1, 
1__photo2, ..., 56__photo1, 56__photo2)

so you call getValue() have the file stored
insert the data in the db, fetch the pk value with lastInsertedId()
and then reapply  the  Rename filter


There is one big difference which is the problem in your assumption.
getValue does NOT return the filename it receives the file and 
makes several other data in background. The filename is not the 
value of the file element.
Looking at Zend_Form_Element_File::getValue() we get the new 
filename after filter are apply. Am I wrong ?



if (!$this-receive()) {
 return null;
}
  $filename = basename($this-getFileName());
$this-_value = $filename;
return $filename;



So the logical way in my opinion would be to call getFileName, 
change the name according to the primary key of the database by 
applying the rename filter, and then, as last step calling 
getValues().
The problem here is that I have to call getValues() first to have 
the data save in the db and get the last Inserted Id

If validation or anything other fails, revert db entry.
You could even validate before attaching the rename filter because 
validation does not receive the file.


if ($file-isValid()) {
   $file-getFileName();
   get id, rework filename
   $file-addFilter('rename', $newfilename);
 -getValues();
}

I have tried something like below after a call to getValues() and 
getting the last Inserted Id  $uid
It is working all find except when my file is not require and it is 
send with the form.
I don't know where to check if the file have been send with the form 
or not. isReceived()  return true in both case photo (file attach or 
not to the form). May be there is a need for an other flag like 
$this-_files[$file]['submited'] ?



   $sourceName = $this-_form-getElement('photo')-getFileName();
   require_once 'Zend/Filter/File/Rename.php';
   $options = array(
   'source' = $sourceName ,
   'target' = $_SERVER['DOCUMENT_ROOT'] . 'medias/news/photos/' 
. $uid . '__photo' ,

   'overwrite' = true);
   $renameFileFilter = new Zend_Filter_File_Rename($options);
   $renameFileFilter-filter($sourceName);







--
Laurent Melmoux
Conseil et Solutions Web | [EMAIL PROTECTED]
2mx - Annecy, France | http://laurent.2mx.fr/
Tél. | +33 (0)9 74 53 10 40



[fw-general] Broken Zend_Db_Select::joinUsing() for several releases

2008-12-05 Thread Colin Guthrie

Hi,

I'm just getting around to converting some queries in my system to using 
Zend_Db_Select (in the cases where I need such specific functionality).


I was a little surprised to uncover a bug in Zend_Db_Select as I'd 
expect this is one area that is fairly heavily unit tested (i've not 
looked, it's just a guess) and also an area that quite a few people 
would use.


But I noticed that it is producing incorrect SQL. It's not that fact 
that joinUsing() does not actually use the SQL USING() clause (I'm not 
sure how standard that is to be honest - could be a MySQLism), it's more 
the fact it totally messes up when table aliases are used!


I found this bug:
http://framework.zend.com/issues/browse/ZF-3309

I was very surprised to see that this was added in May, well over six 
months ago.


While I've been using Zend for a while, and not been hit by this bug, 
I'm surprised this kind of thing has been left unfixed for so long!


I'll try and work on a fix as without it I'll have to write a whole heap 
of more verbose code that I'd rather do without!



Col

--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



[fw-general] Re: Broken Zend_Db_Select::joinUsing() for several releases

2008-12-05 Thread Colin Guthrie

'Twas brillig, and Ralph Schindler at 05/12/08 15:20 did gyre and gimble:

Hi Colin,
 

I'll try and work on a fix as without it I'll have to write a whole heap
of more verbose code that I'd rather do without!


Do you have any interest in taking this on? Fixing it? If so, great!

In the mean time, I will reassign to myself and work up a unit test for it.
It seems like it could be a relative easy fix.


I've attached a fix to the ticket now (no idea if it's the perfect fix 
or not but I just copied the code from _join() a little and threw out 
some bits that were not needed), so hopefully it will pass your unit test :)


Sadly while doing that work, I noticed another problem which I reported as:
http://framework.zend.com/issues/browse/ZF-5165
which means that chaining multiple joinUsing() calls one after the other 
does not link one table to the next, it always goes back to the original 
from() table which is quite different to the SQL USING() syntax.


Sadly, even if I fixed that, I'm not sure it would be allowed in as it 
would change the nature of the call (even although it is not mentioned 
in the docs if this is the intended behaviour or not).


So not quite sure what to do there.

Col



--

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
  Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
  Mandriva Linux Contributor [http://www.mandriva.com/]
  PulseAudio Hacker [http://www.pulseaudio.org/]
  Trac Hacker [http://trac.edgewall.org/]



RE: [fw-general] Validating JQuery forms via AJAX

2008-12-05 Thread ramusus

Hi, Xavier!

It will be very interesting to see you idea in work, can you show your
sources anywhere?


-- 
View this message in context: 
http://www.nabble.com/Validating-JQuery-forms-via-AJAX-tp20698748p20858693.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Best Approach for complex site code structure

2008-12-05 Thread Thorsten Ruf
take a look at the following page:
http://webfractor.wordpress.com/2008/08/14/using-zend-framework-from-the-command-line/


On Thu, Dec 4, 2008 at 15:55, keith Pope [EMAIL PROTECTED] wrote:

 If you need to use cron from cmd line, I would suggest looking at the
 request object, you can easily make your own that will translate cmd
 options to request vars that the MVC components can use.


 2008/12/4 Rob Riggen [EMAIL PROTECTED]:
  I'm doing these things on some sites (except maybe the command line
 calls).
  The standard Zend Recommended structure works just fine for all of it.
 
  I created an MVC controller for the Rest service, as well as one for
  XML-RPC.  I also have a controller specifically for cron jobs that cron
  tasks can call using curl or lynx or something like that.
 
  I hope this helps,
 
  Rob
 
  On Thu, Dec 4, 2008 at 2:32 AM, SteveWilhelm [EMAIL PROTECTED]
  wrote:
 
  I am looking for suggestions on how to structure my Zend code for
  implementing a site that contains the following features:
 
  1. MVC-based code for the public website
  2. A REST-based server to provide programmatic access to application
 data
  3. Admin utility functions that are run by cron jobs and on demand on a
  command line
  4. Utility classes that are shared by all three of the above.
 
  Is there a good example or tutorial that demonstrates how to structure
  code
  for this type of site?
 
  Thanks in advance for your help.
 
  - Steve W.
  --
  View this message in context:
 
 http://www.nabble.com/Best-Approach-for-complex-site-code-structure-tp20828590p20828590.html
  Sent from the Zend Framework mailing list archive at Nabble.com.
 
 
 
  Rob Riggen [EMAIL PROTECTED]



 --
 --
 [MuTe]
 --



[fw-general] Zend dojo Editor does not pass value

2008-12-05 Thread vladimirn

Does any one know how to solve that?
I read over a mailing list, but did not find any suitable solution. So i am
kinda stucked here.
There is my actionView:
**
$form = new Zend_Dojo_Form ( );
$form-setMethod ( 'post' )-setAction ( process )-setName ( 
'editNews'
);
$form-setDecorators ( array ('FormElements', array 
('TabContainer', array
('id' = 'tabContainer', 'style' = 'width: 600px; height: 500px;',
'dijitParams' = array ('tabPosition' = 'top' ) ) ), 'DijitForm' ) );
$newsData = new Zend_Dojo_Form_SubForm ( );
$newsData-setAttribs ( array ('name' = 'News Editing', 
'legend' =
'Personal Data', 'style' = 'width:300px;float:left' ) )-setDecorators (
array ('FormElements', array ('HtmlTag', array ('tag' = 'dl' ) ),
'ContentPane' ) );
$newsData-addElement ( 'ValidationTextBox', 'Posted by', array 
('label'
= 'First Name:', 'lowercase' = 'true', 'maxlength' = 20, 'regExp' =
'\w{2,}', 'required' = true, 'invalidMessage' = 'First Name should have
been longer then 1 character??', 'filters' = array ('StringTrim',
'StringToLower' ), 'validators' = array ('NotEmpty', array ('StringLength',
true, array (2, 20 ) ), array ('Regex', true, array ('/\w+/i' ) ) ) )
)-addElement ( 'editor', 'content', array ('plugins' = array ('undo', '|',
'bold', 'italic' ), 'editActionInterval' = 2, 'focusOnLoad' = true,
'height' = '250px', 'inheritWidth' = true ) )-addElement (
'validationTextBox', 'password', array ('type' = 'password', 'label' =
'Password', 'lowercase' = 'true', 'maxlength' = 20, 'regExp' = '\w{6,}',
'required' = true, 'invalidMessage' = 'Password must be longer then 6
characters.', 'filters' = array ('StringTrim', 'StringToLower' ),
'validators' = array ('NotEmpty', array ('StringLength', true, array (6, 20
) ), array ('Regex', true, array ('/\w+/i' ) ) ) ) )-addElement (
'SubmitButton', 'submit', array ('label' = 'Submit!', 'style' =
'clear:both' ) );
$form = $form-addSubForm ( $newsData, 'personalData' );
$this-view-newsEditForm = $form;
**

after processing data to proccessAction() i am getting this:
array(1) {
  [personalData] = array(3) {
[Postedby] = string(9) asdasdasd
[content] = string(0) 
[password] = string(9) asdasdasd
  }
}

As you can see, content from Editor element is not in $_POST 

Thank you,
V
-- 
View this message in context: 
http://www.nabble.com/Zend-dojo-Editor-does-not-pass-value-tp20860862p20860862.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend dojo Editor does not pass value

2008-12-05 Thread Giorgio Sironi
2008/12/5 vladimirn [EMAIL PROTECTED]

 As you can see, content from Editor element is not in $_POST


I had a similar problem using the programmatic model of dojo, switching to
declarative solved the issue.

-- 
Giorgio Sironi
Piccolo Principe  Ossigeno Scripter
http://www.sourceforge.net/projects/ossigeno


Re: [fw-general] Zend dojo Editor does not pass value

2008-12-05 Thread vladimirn

Thank you very much :)

Giorgio Sironi wrote:
 
 2008/12/5 vladimirn [EMAIL PROTECTED]
 
 As you can see, content from Editor element is not in $_POST

 
 I had a similar problem using the programmatic model of dojo, switching to
 declarative solved the issue.
 
 -- 
 Giorgio Sironi
 Piccolo Principe  Ossigeno Scripter
 http://www.sourceforge.net/projects/ossigeno
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend-dojo-Editor-does-not-pass-value-tp20860862p20861401.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Problems with View Helpers with update 1.5.1 to 1.7.1

2008-12-05 Thread kabel2

Any other ideas on what might be causing this?

Is anyone else able to duplicate this error? Here is my setup:

1) Rewrites in place in .htaccess
2) Bootstrap sets up front controler, view, and layout
3) The layout is outside the controller/module file system design
4) The layout's .phtml file echos $this-layout()-content

I can make my source available if needed.

--
Kevin Abel


Matthew Weier O'Phinney-3 wrote:
 
 -- Terre Porter [EMAIL PROTECTED] wrote
 (on Wednesday, 03 December 2008, 02:12 PM -0500):
 Couple of things,
 
 Would the \ in [/views\helpers/] cause problems in windows path?
 
 No. PHP on Windows is smart enough to figure that out.
 
 C:/Program Files/Apache Software
 Foundation/Apache2.2/htdocs/mbm/app/modules/config/views\helpers/ 
 
 Also, the error doesn't say it is using [library/Zend/View/Helper] as an
 include path.
 
 The paths printed are plugin paths, not the include_path. Any relative
 paths on there will be searched on the include_path.
 

-- 
View this message in context: 
http://www.nabble.com/Problems-with-View-Helpers-with-update-1.5.1-to-1.7.1-tp20807841p20861693.html
Sent from the Zend Framework mailing list archive at Nabble.com.



Re: [fw-general] Zend_Form Decorator

2008-12-05 Thread chinaski

Hi.

In this case, 

$element-setDecorators('UserActiveRadio');

This will work provided the form can find the UserActiveRadio.php decorator
script.

In this case:

$form-addPrefixPath('My_Form_Decorator','My/Form/Decorator', 'decorator');

chinaski



chinaski wrote:
 
 
 chinaski wrote:
 
 I need some help with form decorator. I need help decorating a radio
 group. Here is the group as defined in the init() method of my form
 subclass:
 
 Appreciate help on setting the decorators for this element.
 
 Chinaski
 
 
 
 I came up with a working solution, but it seems like an awful lot of work
 to get some html set up. I did a custom decorator for this particular
 situation, which looks like this.
 
 class My_Form_Decorator_UserActiveRadio extends
 Zend_Form_Decorator_Abstract
 {
public function render($content)
{
   $element = $this-getElement();
   if (!$element instanceof Zend_Form_Element_Multi) {
  return $content;
   }
   if (null === ($view = $element-getView())) {
  return $content;
   }
 
   $translator = $element-getTranslator();
 
   $html = '';
   $radio_selected_value = $element-getValue();
 
   $base_name = $element-getName();
 
   $html .= PHP_EOL . 'fieldset class=checks';
   if ($element-isRequired()) {
  $html .= PHP_EOL . 'h5' . $element-getLabel() .
 'emrequired/em/h5';
   }
   $html .= PHP_EOL . 'ul';
   $tmp = 0;
   foreach ($element-getMultiOptions() as $radio_value) {
  $tmp ++;
  $radio_id = $base_name . $tmp;
  $attribs = array('id'=$radio_id);
  $options = array($values);
 
  $html .= PHP_EOL . 'li' . PHP_EOL . 'input type=radio
 name=' . $base_name . ' id='
 . $radio_id . ' value=' . $radio_value . ' '
 . $this-is_checked($radio_value,$radio_selected_value) .  '
 /'
 . PHP_EOL . 'label for=' . $radio_id . '' . $radio_value .
 '/label' . PHP_EOL . '/li';
   }
   $html .= PHP_EOL . '/ul' . PHP_EOL . '/fieldset!--checks--';
   return $html;
}
 
private function is_checked($option, $value)
{
   if($option == $value) {
  return 'checked';
   }
}
 }
 
 Setting this decorator on the element yields the proper html.
 
 If someone who is adept with the decorator stack can illustrate an easier
 way to accomplish the same thing, it would be appreciated.
 
 

-- 
View this message in context: 
http://www.nabble.com/Zend_Form-Decorator-tp18270378p20863281.html
Sent from the Zend Framework mailing list archive at Nabble.com.



[fw-general] SubForm Label

2008-12-05 Thread Bradley Holt
I have a SubForm that and I'd like to set the content of its related dt.
This is the first part of what I'm currently getting:

dtnbsp;/dtddfieldset id=fieldset-phonedl...

What I want to do is replace the nbsp; above with the word Phones. It
appears that there is no setLabel on SubForms like there is on form
elements. There is a setLegend but that does not affect the dt, it only adds
a legend element:

dtnbsp;/dtddfieldset id=fieldset-phonelegendPhones/legend
dl...

My guess is that I need to get a reference to the DtDdWrapper decorator and
set an option on that. However, I'm not sure what option(s) I'd use:

$phoneSubForm-getDecorator('DtDdWrapper')-setOption('?',
'Phones');

Is this possible and if so am I going about it all wrong?

Thanks,
Bradley

-- 
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] SubForm Label

2008-12-05 Thread Matthew Weier O'Phinney
-- Bradley Holt [EMAIL PROTECTED] wrote
(on Friday, 05 December 2008, 07:09 PM -0500):
 I have a SubForm that and I'd like to set the content of its related dt. This
 is the first part of what I'm currently getting:
 
 dtnbsp;/dtddfieldset id=fieldset-phonedl...
 
 What I want to do is replace the nbsp; above with the word Phones. It
 appears that there is no setLabel on SubForms like there is on form elements.
 There is a setLegend but that does not affect the dt, it only adds a legend
 element:
 
 dtnbsp;/dtddfieldset id=fieldset-phonelegendPhones/legend
 dl...
 
 My guess is that I need to get a reference to the DtDdWrapper decorator and 
 set
 an option on that. However, I'm not sure what option(s) I'd use:
 
 $phoneSubForm-getDecorator('DtDdWrapper')-setOption('?', 'Phones');
 
 Is this possible and if so am I going about it all wrong?

The DtDdWrapper actually doesn't have an option for that. You have two
options here.

Short term, create your own drop-in substitute for DtDdWrapper, and push
in this functionality. This is pretty trivial to achieve -- something
like this:

class My_Form_Decorator_DtDdWrapper extends Zend_Form_Decorator_DtDdWrapper
{
public function render($content)
{
$dt = $this-getOption('dt');
if (null === $dt) {
$dt = 'nbsp;';
}
return 'dt' . $dt . '/dtdd' . $content . '/dd';
}
}

Long term, put an issue in the issue tracker to add support for
providing the dt content.

-- 
Matthew Weier O'Phinney
Software Architect   | [EMAIL PROTECTED]
Zend Framework   | http://framework.zend.com/


[fw-general] Re: SubForm Label

2008-12-05 Thread Bradley Holt
OK, I answered my own question by searching through the mailing list
archive in my email. I'd link to it but I can't find it in Nabble for
some reason but it was a post by Amr Mostafa on Jun 7, 2008. I
extended Zend_Form_SubForm to create something like this:

class My_SubForm extends Zend_Form_SubForm
{
protected $_label;

public function setLabel($label)
{
$this-_label = $label;
return $this-_label;
}

public function getLabel()
{
return $this-_label;
}

public function isRequired()
{
return false;
}

public function loadDefaultDecorators()
{
parent::loadDefaultDecorators();
$this-removeDecorator('DtDdWrapper');
$this-addDecorator('Label', array('tag' = 'dt'));
}
}

Then, in my form code (since I've now got a setLabel method):

$phoneSubForm = new My_SubForm();
$phoneSubForm-setLabel('Phones');
$this-addSubForm($phoneSubForm, 'phone');

Which gets me (mostly) what I want:

dtlabel for=phone class=optionalPhones/label/dt
fieldset id=fieldset-phonedl...

This leaves me with a label that doesn't actually tie back to any form
element (hence, I'm guessing, the reason why the default
implementation of SubForm doesn't use label, but fieldset and legend
instead).

Thanks,
Bradley

On Fri, Dec 5, 2008 at 7:09 PM, Bradley Holt [EMAIL PROTECTED] wrote:

 I have a SubForm that and I'd like to set the content of its related dt. This 
 is the first part of what I'm currently getting:

 dtnbsp;/dtddfieldset id=fieldset-phonedl...

 What I want to do is replace the nbsp; above with the word Phones. It 
 appears that there is no setLabel on SubForms like there is on form elements. 
 There is a setLegend but that does not affect the dt, it only adds a legend 
 element:

 dtnbsp;/dtddfieldset id=fieldset-phonelegendPhones/legend
 dl...

 My guess is that I need to get a reference to the DtDdWrapper decorator and 
 set an option on that. However, I'm not sure what option(s) I'd use:

 $phoneSubForm-getDecorator('DtDdWrapper')-setOption('?', 'Phones');

 Is this possible and if so am I going about it all wrong?

 Thanks,
 Bradley

 --
 Bradley Holt
 [EMAIL PROTECTED]




--
Bradley Holt
[EMAIL PROTECTED]


Re: [fw-general] SubForm Label

2008-12-05 Thread Bradley Holt
Matthew,

That certainly looks simpler than what I came up with. I'm guessing
it's a better option too, since you suggested it :-)

Thanks,
Bradley

On Fri, Dec 5, 2008 at 7:37 PM, Matthew Weier O'Phinney
[EMAIL PROTECTED] wrote:
 -- Bradley Holt [EMAIL PROTECTED] wrote
 (on Friday, 05 December 2008, 07:09 PM -0500):
 I have a SubForm that and I'd like to set the content of its related dt. This
 is the first part of what I'm currently getting:

 dtnbsp;/dtddfieldset id=fieldset-phonedl...

 What I want to do is replace the nbsp; above with the word Phones. It
 appears that there is no setLabel on SubForms like there is on form elements.
 There is a setLegend but that does not affect the dt, it only adds a legend
 element:

 dtnbsp;/dtddfieldset id=fieldset-phonelegendPhones/legend
 dl...

 My guess is that I need to get a reference to the DtDdWrapper decorator and 
 set
 an option on that. However, I'm not sure what option(s) I'd use:

 $phoneSubForm-getDecorator('DtDdWrapper')-setOption('?', 'Phones');

 Is this possible and if so am I going about it all wrong?

 The DtDdWrapper actually doesn't have an option for that. You have two
 options here.

 Short term, create your own drop-in substitute for DtDdWrapper, and push
 in this functionality. This is pretty trivial to achieve -- something
 like this:

class My_Form_Decorator_DtDdWrapper extends Zend_Form_Decorator_DtDdWrapper
{
public function render($content)
{
$dt = $this-getOption('dt');
if (null === $dt) {
$dt = 'nbsp;';
}
return 'dt' . $dt . '/dtdd' . $content . '/dd';
}
}

 Long term, put an issue in the issue tracker to add support for
 providing the dt content.

 --
 Matthew Weier O'Phinney
 Software Architect   | [EMAIL PROTECTED]
 Zend Framework   | http://framework.zend.com/




-- 
Bradley Holt
[EMAIL PROTECTED]