I am trying to have a form with a collection of forms that will allow me to fill in weekly data. I have an Entity that is for the week with a few stats
/**
* @ORM\Column(type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $week_id;
/**
* @ORM\Column(type="string")
*/
protected $area_worked;
/**
* @ORM\OneToMany(targetEntity="User")
*/
protected $approved_by;
/**
* @ORM\OneToMany(targetEntity="DailyStats")
*/
protected $daily_stats;
Then i have the daily stats entity:
/**
* @ORM\Column(type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
protected $day_id;
/**
* @ORM\ManyToOne(targetEntity="WeeklyStats")
*/
protected $weekly_stat_id;
/**
* @ORM\Column(type="float")
*/
protected $hours_worked;
/**
* @ORM\Column(type="integer")
*/
protected $day_of_week;
Then with both of these i want a form that i can output into a table showing the whole week:
Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday
Hours | | | | | | |
However when i put this into a form:
//weekly stats form
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('dailyReports', 'collection',array(
'type'=>new DailyStatsForm(),
'options' => array(
'required' => false
),
'allow_add' => true,
));
}
this generates a form with an empty field set. I can use the javascript to add a field to it but I want to know if its possible to just always generate the 7 days in a keep for this form along with the other fields for the weekly stats?
Any suggestions of solutions would be greatly appreciated.