FAQ
Hi Carl,

thanks for your help, it works great. The only problem left is that i can't get constraints working on that multi element. I get the following error message "no field names to add constraint to at /usr/loc...".
the fields of course are set using the setup method.

how can i solve this one ??
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal f?r Modem und ISDN: http://www.gmx.net/de/go/smartsurfer

Search Discussions

  • Carl Franks at Jun 1, 2007 at 10:38 am

    On 01/06/07, Thorsten Domsch wrote:
    thanks for your help, it works great. The only problem left is that i can't
    get constraints working on that multi element. I get the following error
    message "no field names to add constraint to at /usr/loc...".
    the fields of course are set using the setup method.
    If you don't include any code of what you've tried so far - it's hard
    to try to help.

    Have you done everything I suggested in the first mail?
    Are you trying to add the constraint to the block or it's sub-elements?
    If block - have you given the block element itself a name, and are you
    using that when you define the constraint?
    Because constraint() behaves differently depending on whether you're
    calling it on a field or a block, you'll have to make sure you define
    the 'name' if you're wanting it attached to the block.

    (and could you try to reply to earlier messages rather than starting a
    new thread when it's still the same problem / subject - it makes it
    easier for people searching the archive later to see if the problem
    was solved)

    Cheers,
    Carl
  • Thorsten Domsch at Jun 1, 2007 at 10:52 am
    Hello Carl,

    here's a snippet from my yml file so you can see how i use the field:

    - type: date
    name: justadate
    start_year: 1977
    end_year: 2010
    constraints:
    - Required
    comment: please choose a correct date

    so i guess it should be alright... but doesn't work. Error like i wrote
    "no field names to add constraint to at /usr/loc..."

    (sorry about the reply thing.... you're right of course)
    --
    Psssst! Schon vom neuen GMX MultiMessenger geh?rt?
    Der kanns mit allen: http://www.gmx.net/de/go/multimessenger
  • Carl Franks at Jun 1, 2007 at 11:01 am

    On 01/06/07, Thorsten Domsch wrote:
    Hello Carl,

    here's a snippet from my yml file so you can see how i use the field:

    - type: date
    name: justadate
    start_year: 1977
    end_year: 2010
    constraints:
    - Required
    comment: please choose a correct date

    so i guess it should be alright... but doesn't work. Error like i wrote
    "no field names to add constraint to at /usr/loc..."
    ah, the constraints are being added during the creation of the date
    element - before your setup() has run and added the sub-elements.
    I think to get around that, you'll have to do something like:

    ---
    elements:
    - type: block
    name: justadate
    start_year: 1977
    end_year: 2010
    comment: please choose a correct date

    constraints:
    - type: Required
    name: [date_year, date_month, date_day]
  • Thorsten Domsch at Jun 1, 2007 at 1:00 pm
    Hi Carl,

    this is actually quite unsatisfying.... mayber theres a better way ? like adding the constraint in the setup method ? right after the from has been build ? would that work ?
    --
    Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
    Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
  • Carl Franks at Jun 1, 2007 at 1:24 pm
    would that work ?
    have you tried? - I can't think of any reason it wouldn't work
  • Thorsten Domsch at Jun 1, 2007 at 2:24 pm
    Hi Carl,

    it's a petty but it doesn't work. I've tried something like this :

    sub setup{

    ...

    my $years =
    $self->form->element({ type => 'select', name => $self->name."_year", options => \@options } );

    $years->constraints({ type=> 'Required', message=>'error1' });
    $years->constraints({ type=> 'AllOrNone', message=>'error2', others=>[ $self->name.'_months', $self->name.'_days' ] });

    ...
    return $self;
    }

    what i get is a somewhat strange behaviour, the reqired constraint is fired always, except all three selectboxes are chosen, in this case the allornone
    constraint throwas an exception. So in the case above theres no possibility
    to successfully submit the form.
    Besides that being a very strange behaviour it in't even near what i want to do, namely $self->constraint({type = 'Required'... for example

    But it looks like it's impossible to add a constraint to a multi field ?? but thats what i need to do...








    --
    Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
    Browser-Versionen downloaden: http://www.gmx.net/de/go/browser

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedJun 1, '07 at 9:10a
activeJun 1, '07 at 2:24p
posts7
users2
websitemetacpan.org...

2 users in discussion

Thorsten Domsch: 4 posts Carl Franks: 3 posts

People

Translate

site design / logo © 2022 Grokbase