title: Nesting Models Relations In Forms - Laravel
body: <p>In laravel, is there some way of nesting related resources in a form?</p>
  
  <p>Say I have this:</p>
  
  <pre><code>class Person extends Eloquent {
    public function addresses() {
      return $this-&gt;hasMany("Address");
    }
  }
  
  class Address extends Eloquent {
    public function person() {
      return $this-&gt;belongsTo("Person");
    }
  }
  </code></pre>
  
  <p>and I want a <code>Person</code> form to collect information about that <code>Person</code>'s <code>Address</code>es. Does laravel facilitate this in a way that is equivalent to Rails' <code>accepts_nested_attributes_for :address</code> and <code>fields_for :address</code>?</p>
  
  <p>I'd just like something simple where I can include the <code>Address</code> fields with the results of the <code>Person</code> form, since the <code>Address</code> doesn't really exist apart from the <code>Person</code>. Does this make sense?</p>
  
  <p><strong>== EDIT ==</strong></p>
  
  <p><em>This is hypothetical code</em></p>
  
  <p>What I'm looking for is something that would resemble this:</p>
  
  <pre><code>{{ Form::model(new Person, array("action" =&gt; "admin\PersonController@store", "method" =&gt; "POST")) }}
  
  {{ Form::text("name", array(...)) // &lt;input name='person[name]' ... /&gt; }}
  
  
  {{ Form::email("email", array(...)) // &lt;input name='person[email]' ... /&gt; }}
  
  {{ Form::fields_for("addresses"/* Would be name of relation */) }}
  
    {{ Form::text("street_address") // &lt;input name='person[addresses][][street_address]' ... /&gt; }}
  
  {{ Form::close_fields() }}
  
  {{ Form::close() }}
  </code></pre>