[html-formfu] Constraint "Required" with condition "when" doesn't work in apache-style config

Carl Franks fireartist at gmail.com
Sat Nov 29 00:57:53 GMT 2008


2008/11/28 Christoph Metz <mail-lao at web.de>:
> Carl Franks wrote:
>>
>> 2008/11/28 Christoph Metz <mail-lao at web.de>:
>>
>>>
>>> using an Require constraint whith the "when" condition doesn't work fine
>>> for
>>> me :/
>>>
>>> <element>
>>>          type Select
>>>            name kompetenzfeld_id
>>>            <constraint>
>>>              type Required
>>>              <when>
>>>                  field extern
>>>                  values 0
>>>                </when>
>>>          </constraint>
>>> </element>
>>>
>>>
>>> without the "<when>" part the Required constrain works correctly, maybe
>>> the
>>> syntax of my conf isn't correct, but this was the only variant,
>>> (config-loader) formfu accepted so far...
>>>
>>
>> That config seems to work, looking at a dumped $form, so the problem
>> must either be a misunderstanding of how it's meant to work, or a bug.
>> Note that the when() doesn't yet support nested params, such as "foo.bar".
>>
>> Can you write a failing test file, that demonstrates what you expect
>> to happen, to help start to narrow it down?
>>
>> Cheers,
>> Carl
>>
>> _______________________________________________
>> HTML-FormFu mailing list
>> HTML-FormFu at lists.scsys.co.uk
>> http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu
>>
>>
>
> thanks carl,
>
> the radio-button and the field asking for it with "when()" are nested in 2
> divs... damn. Are there any other possibilities to do this kind of stuff,
> without validating each param by myself AND with the ability to access these
> magic method across blocks, like some divs?

If it's just normal nested Blocks without a nested_name set, then it
should be fine.
It's only nested-params that don't work - that's when an outer block
has a nested_name(), such as:

type: Block
nested_name: foo
elements:
    - type: Text
      name: bar

Which would cause the Text field to actually get the name "foo.bar"

Carl



More information about the HTML-FormFu mailing list