auraphp / Aura.Input

Tools to describe HTML form fields and values.
MIT License
65 stars 11 forks source link

Add an empty row to the collection #34

Closed dmolineus closed 9 years ago

dmolineus commented 10 years ago

I really like the idea of collections and fieldsets in Aura, but I struggle at some points. Here is another one.

At the moment an collection can only be rendered if any data is filled in (by a model, by post etc.). It would be great add an empty fieldset row or at least to get the fieldset so I could create empty rows in the View of the collection.

public function addEmptyFieldset()
{
    $index = $this->count();
    $new = $this->newFieldset($index);
    $this->fieldsets[$index] = $new;

    return $new;
}
harikt commented 10 years ago

What is the purpose of empty field set you are looking for ?

dmolineus commented 10 years ago

Let me explain it with the used contact form example in the Aura docs. I want to provide a form where multiple entries of the collection can be added. The number of items should not be limited.

I would like to render an empty fieldset in this cases:

  1. User registers: There is no data filled yet, so the collection would contain no fieldset rows. I want to display an empty row so the first item can be inserted
  2. User edit data: User wants to add a new contact type. There need to be a new row.

I want to use a generic form renderer where I can not know which fieldset is used in the collection. So I need a way getting the fieldset.

harikt commented 10 years ago

ping @pmjones

harikt commented 10 years ago

could you please send a PR, so @pmjones can check the idea? ( preferable with test case ) or you can wait to hear his thoughts.

harikt commented 10 years ago

one thing for now, extend the class ;) .

dabba39 commented 9 years ago

the collection class should not contain rendering concerns. empty fieldsets can be triggered via javascript.