[html-formfu] One to many inserting lots of blank rows

Scott Simpson scott at simpzoid.com
Tue Oct 16 22:25:13 GMT 2012



-----Original Message-----
From: Carl Franks [mailto:fireartist at gmail.com] 
Sent: 16 October 2012 10:30
To: HTML Form Creation, Rendering and Validation Framework
Subject: Re: [html-formfu] One to many inserting lots of blank rows

On 15 October 2012 15:47, scott <scott at simpzoid.com> wrote:
> I have a form with a 1-to-many relationship which uses a repeatable block.
>
> The default behaviour worked perfectly when I only had text boxes. 
> I.e. if the repeatable row contained all blanks no row was inserted 
> into the database if there was something worth inserting it got inserted.
>
> Unfortunately when I added a text field I now get a row for every row 
> in the repeatable block.  Is there a way to change this behaviour so 
> rows with nothing but the default date do not get inserted.l

Hi Scott,

If the Repeatable contains another field which is required for insertion,
you could add the "ignore_if_empty" option to that field - for example

elements:
  - name: title
    model_config:
      ignore_if_empty: 1
  - name: date
    type: Date

Would that work for you here?

Carl

--------------

Carl,

That would work for me OK.  

I did look at that option before my post but couldn't get it to work.  My
config looks like this:

<element>
        name   title
        type    Text
       <model_config>
            ignore_if_empty 1
       </model_config>
</element>
<element>
        name   date
        type    Date
</element>

I have tried lots of variations on this but none of them seem to work.  I am
going to change my config to yaml as that seems to be more common but if you
could point out what is wrong with the above config I'd be grateful.

Scott





More information about the HTML-FormFu mailing list