php - cakePHP: How to change the ID of a form element (using the form helper)? -
i've created form has loop display number of rows. have select on each row using form helper. ids creates same, there way add counter, or defining info id?
i'm using $this->form->input('city_id')
output select of cities city model. ids modelcityid
. i'd modelcityid1, modelcityid2
, modelcityid3
, etc. possible? or there better way go displaying options in loop?
thanks suggestions might have.
here relevant part of code.
while ($current_date != $departure_date) { $current_date = date("d-m-y", strtotime($current_date . " +1 day")); $output .= '<tr>'; $output .= '<td>'.$current_date.'</td>'; // irrelevant other columns $output .= '<td>'.$this->form->input('city_id', array('label' => '', 'empty' => true)).'</td>'; $output .= '</tr>'; }
if ids same, name same well. that'll mess data when submit it. you're looking syntax:
$this->form->input("modelname.$i.city_id", array(...))
use modelname
you're making form (i.e. same in $this->form->create('modelname')
).
Comments
Post a Comment