2008年8月17日星期日

RE: [fw-mvc] Setting a custom parameter for a form

If you take a look at the signature for __construct, you will see the first
arg should be an array of options. I would imagine that you could pass an
empty array as this first arg and then add the rowCount as a second arg but
then you would need to override the constructor.

So, perhaps the 2nd potential solution is better. Just add a createRows (or
whatever you want to name your method) public method to your form class.
Then instantiate the form and call the createRows method. You wouldn't
necessarily need a createRows method as you create the rows wherever, (in
the form class, in a controller, etc.).

Again, I hope that helps.


Gordon Ross-8 wrote:
>
> Matthew Lurz [mlurz71@gmail.com] Wrote:
>
>> First off, init is called when the form is instantiated and so setting
>> the
>> count after the form has been instantiated results in the protected
>> property
>> rowCount being set and nothing more.
>
> I'd guessed that :-(
>
>> 1. Pass the count to init directly instead of calling setCount after the
>> form has been instantiated
>
> Well init is called from the __construct constructor method.
>
> I tried something naive like:
>
> $form = new DummyForm(array('rowCount' => 2));
>
> But it didn't seem to work.
>
>> 2. Move the loop into a separate method
>
> Where ?
>
>> Also, you want to consider creating a DisplayGroup for
>> each row so as to be able to easily reference a given row.
>
> Got that licked already, thanks.
>
> GTG
>
>

--
View this message in context: http://www.nabble.com/Setting-a-custom-parameter-for-a-form-tp19018020p19020250.html
Sent from the Zend MVC mailing list archive at Nabble.com.

没有评论: