On 11/1/06, sbarre <[EMAIL PROTECTED]> wrote:
>
> By inspecting a helper's methods - for this example we'll use
> $html->input() - we can determine the names of the parameters that a
> given method in the helper is expecting.
I like where you're going with this.
php4 compat would be nice but I really don't think there will be a DRY
solution for php4. I'm personally alright with that.
I'd be inclined to use more reflection and allow even cleaner smarty
calls in the templates:
(i.e. {html func="input" fieldName="User/username" size=30 class="oi oi oi"})
This means cleaning expected parameters from the special array
parameter that is to be generated and passed -- it also requires more
work if there are multiple array parameters.
( Though looking through the helpers api it doesn't look like many
helper methods accept multiple array parameters -- looks like they're
mostly in ajax -- I have a couple ideas about how to tackle this
anyhow. )
Additionally, ReflectionParamater->isArray() is only available >= 5.1
So unless 5.1 is a req. then we have to figure out some workaround
Possible solutions
1. match against common names (htmlAttributes, htmlOptions, options)
- ew..
2. introduce array marking parameters:
{helper func="method" fieldName="User/username"
new_array="htmlAttributes" size=20 class="freebeer"
new_array2="otherArray" foo="bar" bar="foo}
would call
$helper->method("User/username",array('size'=>20,'class'='freebeer'),array('foo'=>'bar','bar'=>'foo'));
-- assuming function method($fieldName,$htmlAttributes,$otherArray)
Is #2 worth it? It is a solution for methods accepting multiple arrays as well.
Ultimately I want to find a way to allow that straight native style:
{html func="input" fieldName="User/username" size=30 class="oi oi oi"}
Maybe some combination of ideas presented?
I personally would be happy with:
- 5.1 reflection to transparently pass all smarty parameters that
don't match in helper method in the methods array parameter
- allowed direct setting of array parameters with delimiter parsing
- allowed direct setting using assign_adv (or other array-setting plugin)
Thoughts?
Travis
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/cake-php
-~----------~----~----~----~------~----~------~--~---